Documentation
¶
Overview ¶
Package logging provides an injectable logging contract and a standard-library implementation. Applications select implementations through their DI bindings.
Index ¶
- type Logger
- type Options
- type SlogLogger
- func (l *SlogLogger) Debug(ctx context.Context, message string, fields ...any)
- func (l *SlogLogger) Error(ctx context.Context, message string, fields ...any)
- func (l *SlogLogger) Info(ctx context.Context, message string, fields ...any)
- func (l *SlogLogger) Warn(ctx context.Context, message string, fields ...any)
- func (l *SlogLogger) With(fields ...any) Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger interface {
Debug(context.Context, string, ...any)
Info(context.Context, string, ...any)
Warn(context.Context, string, ...any)
Error(context.Context, string, ...any)
With(...any) Logger
}
Logger writes structured events. Fields are alternating string keys and values, or slog.Attr values when using SlogLogger. Implementations must be safe for concurrent use. With returns a logger with additional fields without changing the receiver. Logging does not exit the process or panic.
type Options ¶
Options configures the default implementation. The zero value writes text events at info level or above to stderr. Output must support concurrent use when shared by independently constructed loggers.
type SlogLogger ¶
type SlogLogger struct {
// contains filtered or unexported fields
}
func New ¶
func New(options Options) *SlogLogger
New creates an independent logger; it never modifies slog's global default.
func NewDefault ¶
func NewDefault() *SlogLogger
NewDefault is the framework's fallback provider. Each DI initialization owns its own instance; this is not a global logger.
func (*SlogLogger) Debug ¶
func (l *SlogLogger) Debug(ctx context.Context, message string, fields ...any)
func (*SlogLogger) Error ¶
func (l *SlogLogger) Error(ctx context.Context, message string, fields ...any)
func (*SlogLogger) Info ¶
func (l *SlogLogger) Info(ctx context.Context, message string, fields ...any)
func (*SlogLogger) Warn ¶
func (l *SlogLogger) Warn(ctx context.Context, message string, fields ...any)
func (*SlogLogger) With ¶
func (l *SlogLogger) With(fields ...any) Logger