logger

package
v0.0.0-...-fcd3143 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

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 Debug

func Debug() *zerolog.Event

Debug logs a message at DebugLevel using the global logger.

func Error

func Error() *zerolog.Event

Error logs a message at ErrorLevel using the global logger.

func Fatal

func Fatal() *zerolog.Event

Fatal logs a message at FatalLevel using the global logger, then exits.

func FromContext

func FromContext(ctx context.Context) *zerolog.Logger

FromContext returns a logger from the given context. If no logger is found, it returns the global logger.

func Info

func Info() *zerolog.Event

Info logs a message at InfoLevel using the global logger.

func Itoa

func Itoa(i int) string

Helper to format integer line numbers as strings (since zerolog requires string conversion)

func NewControllerRuntimeLogger

func NewControllerRuntimeLogger() logr.Logger

NewControllerRuntimeLogger creates a new logr.Logger that uses our zerolog-based logger

func Panic

func Panic() *zerolog.Event

Panic logs a message at PanicLevel using the global logger, then panics.

func Warn

func Warn() *zerolog.Event

Warn logs a message at WarnLevel using the global logger.

func WithContext

func WithContext(ctx context.Context, l *zerolog.Logger) context.Context

WithContext returns a new context that carries the provided logger.

func WithError

func WithError(l *zerolog.Logger, err error) *zerolog.Logger

WithError returns a new logger with the provided error attached. If err is nil, returns the original logger.

func WithValues

func WithValues(l *zerolog.Logger, keysAndValues ...interface{}) *zerolog.Logger

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

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

Jump to

Keyboard shortcuts

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