Documentation
¶
Overview ¶
Package internal holds the logger backend adapters (zap / slog) and the shared OutputFormat / level vocabulary the public logger package translates user input into.
Index ¶
Constants ¶
const ( LogLevelDebug = -1 LogLevelInfo = 0 LogLevelWarn = 1 LogLevelError = 2 LogLevelCritical = 3 )
Variables ¶
This section is empty.
Functions ¶
func NewSlogLogger ¶
func NewSlogLogger(opts ...SlogOption) *slogLogger
NewSlogLogger creates a new slog logger with optional configuration
func NewZapLogger ¶
func NewZapLogger(opts ...ZapOption) *zapLogger
NewZapLogger creates a new zap logger with optional configuration
Types ¶
type Logger ¶
type Logger interface {
Enabled(level int) bool
WithContext(ctx context.Context) Logger
WithFields(fields map[string]any) Logger
WithKeysAndValues(keysAndValues ...any) Logger
Debug(msg string, args ...any)
Warn(msg string, args ...any)
Info(msg string, args ...any)
Error(msg string, args ...any)
Critical(msg string, args ...any)
}
Logger is the interface for internal logger implementations to avoid circular dependencies
type OutputFormat ¶
type OutputFormat string
const ( JSONFormat OutputFormat = "json" TextFormat OutputFormat = "text" )
type SlogOption ¶
type SlogOption func(*slogConfig)
SlogOption defines a function that can modify the slog logger configuration
func WithSlogFormat ¶
func WithSlogFormat(format OutputFormat) SlogOption
WithSlogFormat sets the output format
func WithSlogOutput ¶
func WithSlogOutput(output io.Writer) SlogOption
WithSlogOutput sets the output writer
type ZapOption ¶
type ZapOption func(*zapConfig)
ZapOption defines a function that can modify the zap logger configuration
func WithZapDevelopmentConfig ¶
func WithZapDevelopmentConfig() ZapOption
WithZapDevelopmentConfig sets the development configuration for zap logger
func WithZapOutput ¶
WithZapOutput sets the output writer
func WithZapProductionConfig ¶
func WithZapProductionConfig() ZapOption
WithZapProductionConfig sets the production configuration for zap logger