Documentation
¶
Index ¶
- Constants
- Variables
- func NewLogger(opts ...Opts) logr.Logger
- func SetLevel(level Level) func(o *Options)
- func SetLogger(logger logr.Logger)
- func SetMode(mode Mode) func(o *Options)
- func SetSync(sync io.Writer)
- func SetupOTelLogging(ctx context.Context, config *otel.Config, zapLevel Level, zapMode Mode, ...) (logr.Logger, error)
- func ShutdownOTelLogging(ctx context.Context) error
- type Level
- type Mode
- type Options
- type Opts
Constants ¶
const ( // DebugLevel logs are typically voluminous, and are usually disabled in production. DebugLevel = Level(zapcore.DebugLevel) // InfoLevel is the default logging priority. InfoLevel = Level(zapcore.InfoLevel) // WarnLevel logs are more important than Info, but don't need individual human review. WarnLevel = Level(zapcore.WarnLevel) // ErrorLevel logs are high-priority. If an application is running smoothly, // it shouldn't generate any error-level logs. ErrorLevel = Level(zapcore.ErrorLevel) // DPanicLevel logs are particularly important errors. In development the // logger panics after writing the message. DPanicLevel = Level(zapcore.DPanicLevel) // PanicLevel logs a message, then panics. PanicLevel = Level(zapcore.PanicLevel) // FatalLevel logs a message, then calls os.Exit(1). FatalLevel = Level(zapcore.FatalLevel) )
Variables ¶
var ( // Log is the base logger Log logr.Logger = logr.New(ctrllog.NullLogSink{}) Sync io.Writer )
Functions ¶
func SetLevel ¶
SetLevel sets Options.LogLevel, which configures the the minimum enabled logging level e.g Debug, Info.
func SetLogger ¶
SetLogger sets a concrete logging implementation for all deferred Loggers. Being top level application and not a library or dependency, let's delegation logger used by any dependency
func SetupOTelLogging ¶ added in v1.4.0
func SetupOTelLogging(ctx context.Context, config *otel.Config, zapLevel Level, zapMode Mode, zapWriter io.Writer) (logr.Logger, error)
SetupOTelLogging sets up OpenTelemetry logging with the given configuration. It creates a Zap logger with a Tee core that sends logs to both: - Console output (formatted via Zap encoder) - OTel LoggerProvider (for OTLP export to remote collectors) using official otelzap bridge Returns a logr.Logger that wraps the Zap logger Returns an error if no logs endpoint is configured.
func ShutdownOTelLogging ¶ added in v1.4.0
ShutdownOTelLogging gracefully shuts down the OpenTelemetry logger provider
Types ¶
type Mode ¶
type Mode int8
Mode defines the log output mode.
const ( // ModeProd is the log mode for production. ModeProd Mode = iota // ModeDev is for more human-readable outputs, extra stack traces // and logging info. (aka Zap's "development config".) // https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/log/zap#UseDevMode ModeDev )
type Options ¶
type Options struct {
// LogLevel configures the verbosity of the logging.
LogLevel Level
// LogMode defines the log output mode.
LogMode Mode
// DestWriter controls the destination of the log output. Defaults to
// os.Stderr.
DestWriter io.Writer
}
Options contains all possible settings.