Documentation
¶
Overview ¶
Package stdlib provides a pure stdlib slog logger implementation.
Index ¶
- func NewSlog(cfg Config) *slog.Logger
- type Config
- type Logger
- func (l *Logger) Debug(msg string, keysAndValues ...any)
- func (l *Logger) Error(msg string, keysAndValues ...any)
- func (l *Logger) Info(msg string, keysAndValues ...any)
- func (l *Logger) Warn(msg string, keysAndValues ...any)
- func (l *Logger) With(keysAndValues ...any) interfaces.Logger
- func (l *Logger) WithContext(ctx context.Context) interfaces.Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Level sets the minimum log severity (debug, info, warn, error).
Level string
// AddSource enables source code location in log records.
AddSource bool
}
Config holds stdlib-specific logger configuration.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns stdlib-specific configuration with sensible defaults.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger implements interfaces.Logger using pure stdlib slog.
func (*Logger) Debug ¶
Debug logs a message at debug level with the given key/value attribute pairs.
func (*Logger) Error ¶
Error logs a message at error level with the given key/value attribute pairs.
func (*Logger) With ¶
func (l *Logger) With(keysAndValues ...any) interfaces.Logger
With returns a child logger that includes the given key/value pairs on every subsequent record.
func (*Logger) WithContext ¶
func (l *Logger) WithContext(ctx context.Context) interfaces.Logger
WithContext returns a logger enriched with the correlation, trace, and span IDs found in ctx. The receiver is returned unchanged when none are present.