Documentation
¶
Index ¶
- Constants
- func ContextWithLogger(ctx context.Context, logger *Logger) context.Context
- type Format
- type Level
- type Logger
- func (l *Logger) Debug(msg string, keysAndValues ...any)
- func (l *Logger) Error(err error, msg string, keysAndValues ...any)
- func (l *Logger) GetLogger() logr.Logger
- func (l *Logger) Info(msg string, keysAndValues ...any)
- func (l *Logger) Trace(msg string, keysAndValues ...any)
- func (l *Logger) WithValues(keysAndValues ...any) *Logger
Constants ¶
const ( ErrorLevel = iota InfoLevel DebugLevel TraceLevel JSONFormat Format = "json" ConsoleFormat Format = "console" DefaultFormat Format = ConsoleFormat LogLevelEnvVar = "LOG_LEVEL" LogFormatEnvVar = "LOG_FORMAT" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Format ¶
type Format string
func ParseFormat ¶
ParseFormat parses a string representation of a log format and returns the corresponding Format value or an error if it isn't recognized
type Level ¶
type Level uint32
func ParseLevel ¶
ParseLevel parses a string representation of a log level and returns the corresponding Level value.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a wrapper around logr.Logger that provides a more ergonomic API. This is heavily inspired by a similar wrapper from https://github.com/kubernetes-sigs/cluster-api-provider-aws
func LoggerFromContext ¶
LoggerFromContext extracts a *Logger from the provided context.Context and returns it. If no *Logger is found, a global *Logger is returned.
func NewLoggerOrDie ¶
NewLoggerOrDie returns a new *Logger with the provided log level or panics if there is an error configuring the logger
func (*Logger) GetLogger ¶
GetLogger returns the underlying logr.Logger for cases where one needs to interact with the logr API directly.
func (*Logger) WithValues ¶
WithValues adds key-value pairs to a logger's context.