Documentation
¶
Overview ¶
Package log provides a structured, leveled logging abstraction.
It defines a Logger interface with Debug, Info, Warn, and Error methods. Two implementations are provided:
- StdLogger: writes to an io.Writer with configurable level filtering and text or JSON output format.
- nopLogger: a zero-allocation no-op logger for when logging is disabled.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger interface {
// Debug logs a message at DEBUG level.
Debug(msg string, fields ...string)
// Info logs a message at INFO level.
Info(msg string, fields ...string)
// Warn logs a message at WARN level.
Warn(msg string, fields ...string)
// Error logs a message at ERROR level.
Error(msg string, fields ...string)
// WithLevel returns a new Logger with the given minimum level.
WithLevel(level Level) Logger
}
Logger is the interface for structured, leveled logging. Each method accepts a message and optional key-value pairs. Keys and values are provided as alternating string arguments.
type StdLogger ¶
type StdLogger struct {
// contains filtered or unexported fields
}
StdLogger writes structured log entries to an io.Writer.
Click to show internal directories.
Click to hide internal directories.