Documentation
¶
Index ¶
- func Configure(cfg Config)
- func Debug() *zerolog.Event
- func Error() *zerolog.Event
- func Fatal() *zerolog.Event
- func FromContext(ctx context.Context) *zerolog.Logger
- func Info() *zerolog.Event
- func Itoa(i int) string
- func NewControllerRuntimeLogger() logr.Logger
- func Panic() *zerolog.Event
- func Warn() *zerolog.Event
- func WithContext(ctx context.Context, l *zerolog.Logger) context.Context
- func WithError(l *zerolog.Logger, err error) *zerolog.Logger
- func WithValues(l *zerolog.Logger, keysAndValues ...interface{}) *zerolog.Logger
- type Config
- type ControllerRuntimeAdapter
- func (a *ControllerRuntimeAdapter) Enabled(level int) bool
- func (a *ControllerRuntimeAdapter) Error(err error, msg string, keysAndValues ...interface{})
- func (a *ControllerRuntimeAdapter) Info(level int, msg string, keysAndValues ...interface{})
- func (a *ControllerRuntimeAdapter) Init(info logr.RuntimeInfo)
- func (a *ControllerRuntimeAdapter) WithName(name string) logr.LogSink
- func (a *ControllerRuntimeAdapter) WithValues(keysAndValues ...interface{}) logr.LogSink
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Configure ¶
func Configure(cfg Config)
Configure allows overriding default logger settings. It may be called once at application startup. Subsequent calls have no effect.
func FromContext ¶
FromContext returns a logger from the given context. If no logger is found, it returns the global logger.
func Itoa ¶
Helper to format integer line numbers as strings (since zerolog requires string conversion)
func NewControllerRuntimeLogger ¶
NewControllerRuntimeLogger creates a new logr.Logger that uses our zerolog-based logger
func WithContext ¶
WithContext returns a new context that carries the provided logger.
func WithError ¶
WithError returns a new logger with the provided error attached. If err is nil, returns the original logger.
func WithValues ¶
WithValues returns a new logger with the provided key/value pairs attached as structured fields. Keys must be strings; non-string keys will be replaced with "invalid_key". If an odd number of arguments is passed, the last value is labeled "MISSING_VALUE".
Types ¶
type Config ¶
type Config struct {
// ServiceName is an application/service identifier to be included in every log line.
ServiceName string
// Environment (e.g., "production", "staging", "development").
Environment string
// LogLevel overrides the default log level (Info). Accepts "debug", "info",
// "warn", "error", "fatal", "panic". Case-insensitive.
LogLevel string
// Format can be "json" or "console". Defaults to "console" if unset.
Format string
// TimeFormat sets the timestamp format. Defaults to time.RFC3339Nano.
TimeFormat string
// Output defines the io.Writer for logs. Defaults to os.Stdout.
Output io.Writer
}
Config holds configuration parameters for the global logger. All fields are optional; environment variables will be used as defaults if unset.
type ControllerRuntimeAdapter ¶
type ControllerRuntimeAdapter struct {
// contains filtered or unexported fields
}
ControllerRuntimeAdapter adapts our zerolog-based logger to controller-runtime's logging interface
func (*ControllerRuntimeAdapter) Enabled ¶
func (a *ControllerRuntimeAdapter) Enabled(level int) bool
Enabled implements logr.LogSink
func (*ControllerRuntimeAdapter) Error ¶
func (a *ControllerRuntimeAdapter) Error(err error, msg string, keysAndValues ...interface{})
Error implements logr.LogSink
func (*ControllerRuntimeAdapter) Info ¶
func (a *ControllerRuntimeAdapter) Info(level int, msg string, keysAndValues ...interface{})
Info implements logr.LogSink
func (*ControllerRuntimeAdapter) Init ¶
func (a *ControllerRuntimeAdapter) Init(info logr.RuntimeInfo)
Init implements logr.LogSink
func (*ControllerRuntimeAdapter) WithName ¶
func (a *ControllerRuntimeAdapter) WithName(name string) logr.LogSink
WithName implements logr.LogSink
func (*ControllerRuntimeAdapter) WithValues ¶
func (a *ControllerRuntimeAdapter) WithValues(keysAndValues ...interface{}) logr.LogSink
WithValues implements logr.LogSink