Documentation
¶
Overview ¶
Package logging provides structured logging using log/slog with configurable output format, color support, and output destinations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrInvalidFormat is returned when the log format is invalid. ErrInvalidFormat = errors.New("invalid format: must be text or json") // ErrEmptyOutput is returned when the output destination is empty. ErrEmptyOutput = errors.New("output cannot be empty") )
View Source
var ( // ErrUnsupportedFormat is returned when the format is not supported. ErrUnsupportedFormat = errors.New("unsupported format") )
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Format specifies the log output format (text or json).
Format Format
// Level specifies the minimum log level to output.
Level slog.Level
// Color enables colored output for text format.
// nil (default) = auto-detect based on TTY, true = force on, false = force off.
Color *bool
// Output specifies where to write logs (stderr, stdout, or a file path).
Output Output
// AddSource adds source code position to log records.
AddSource bool
}
Config holds the logging configuration.
Click to show internal directories.
Click to hide internal directories.