Documentation
¶
Overview ¶
Package logger describes interfaces for a logger.Logger and other support elements
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Configuration ¶
type Configuration struct {
ServiceName string `required:"true" envconfig:"SVC_NAME"`
LogLevel string `required:"false" envconfig:"LOG_LEVEL" default:"info"`
LoggerType LoggerType `required:"false" envconfig:"LOGGER_TYPE" default:"zap"`
}
type Logger ¶
type Logger interface {
Enabled(level int) bool
WithContext(ctx context.Context) Logger
WithFields(fields LogFields) Logger
WithKeysAndValues(keysAndValues ...any) Logger
IsLevelEnabled(level LogLevel) bool
// Context-aware methods
DebugContext(ctx context.Context, msg string, args ...any)
InfoContext(ctx context.Context, msg string, args ...any)
WarnContext(ctx context.Context, msg string, args ...any)
ErrorContext(ctx context.Context, msg string, args ...any)
CriticalContext(ctx context.Context, msg string, args ...any)
// Non-context methods
Debug(msg string, args ...any)
Info(msg string, args ...any)
Warn(msg string, args ...any)
Error(msg string, args ...any)
Critical(msg string, args ...any)
}
type LoggerType ¶
type LoggerType string
LoggerType defines the type of logger implementation
const ( ZapLogger LoggerType = "zap" SlogLogger LoggerType = "slog" )
Click to show internal directories.
Click to hide internal directories.