logging

package
v0.6.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package logging owns the controller's root logger construction: a single zap.Logger (Init, guarded by sync.Once so repeated calls are safe and always return the same instance) wrapped as a logr.Logger (AsLogr) for controller-runtime's consumption.

Config selects which sinks feed that logger — console, a rotated local file, and/or Papertrail/SolarWinds over syslog — and buildZap (zap.go) wires them together as a zapcore.Tee. Papertrail connection failure is deliberately non-fatal (buildPapertrailCore logs to stderr and returns nil rather than erroring): losing a remote log sink shouldn't crash the controller.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsLogr

func AsLogr(z *zap.Logger) logr.Logger

AsLogr wraps a zap.Logger as a logr.Logger.

func Init

func Init(cfg Config) (logr.Logger, *zap.Logger, error)

Init builds the root zap logger from cfg on first call and returns it (wrapped as logr.Logger) plus the underlying *zap.Logger. Subsequent calls return the same root logger regardless of cfg.

func SetupPapertrailJSONIngest

func SetupPapertrailJSONIngest(token string) func(msg string) error

SetupPapertrailJSONIngest returns a function that sends JSON logs directly to Papertrail / SolarWinds HTTP ingestion API.

This is intentionally decoupled from zap: - no global logger - no side effects - safe to use from controllers, jobs, or goroutines

Types

type Config

type Config struct {
	Development bool

	Console  bool
	File     bool
	FilePath string

	Level string // "debug", "info", "warn", "error"

	EnablePapertrail bool
	PapertrailAddr   string
	PapertrailTag    string
}

Config configures the root logger's output (console/file/Papertrail) and verbosity.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a development-mode Config: console output only, info level, no file or Papertrail sink.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL