Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLogger ¶
NewLogger creates a new instance of slog.Logger. The logging level can be specified by level. The returned logger writes info messages to STDOUT and warning, error, and debug messages to STDERR. The messages are color-coded for readability: debug messages are light gray, warning messages are yellow, and error messages are red.
Types ¶
type ColorWriter ¶
type ColorWriter struct {
// contains filtered or unexported fields
}
ColorWriter is a custom writer that adds color to the output.
type LogHandler ¶
type LogHandler struct {
slog.Handler
Debug *log.Logger
Info *log.Logger
Warn *log.Logger
Error *log.Logger
}
LogHandler is a custom slog handler that routes log messages to different loggers based on their severity level. It embeds slog.Handler and defines loggers for different severity levels like Debug, Info, Warn, and Error.
Click to show internal directories.
Click to hide internal directories.