Documentation
¶
Overview ¶
Package logging builds the application's structured logger on top of the standard library's log/slog. The composition root constructs a *slog.Logger with New and injects it into the components that need it (dependency inversion: there is no package-level logger and slog.SetDefault is never called, so logging is an explicit dependency rather than ambient global state).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New builds a *slog.Logger that writes JSON records — including the source file:line — at or above cfg.Level to cfg.Writer.
func ParseLevel ¶
ParseLevel maps a level name to a slog.Level, case-insensitively and ignoring surrounding whitespace. An empty string defaults to Info with no error (an unset env var is not a misconfiguration). "warning" is accepted as an alias for "warn". An unrecognized non-empty value returns Info plus a *LevelError so the caller can fall back safely while still surfacing the typo.
Types ¶
type Config ¶
type Config struct {
// Writer is the destination for log records. A nil Writer is treated as
// io.Discard so a misconfiguration drops logs rather than panicking on first use.
Writer io.Writer
// Level is the minimum severity emitted; records below it are dropped.
Level slog.Level
}
Config configures a logger built by New.
type LevelError ¶
type LevelError struct {
Value string
}
LevelError reports a log-level string that ParseLevel did not recognize.