Documentation
¶
Overview ¶
Package slogor provides a colorful slog handler.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type GroupOrAttrs ¶ added in v1.2.0
type GroupOrAttrs struct {
// contains filtered or unexported fields
}
type Handler ¶
type Handler struct { Writer io.Writer // Writer is the destination for the log records. Mutex *sync.Mutex // Mutex for handling concurrent access to the handler. Options options // Options is the configuration for the log handler. // contains filtered or unexported fields }
Handler is a slog.Handler that writes Records to an io.Writer as a sequence of colorful time, message, and pairs separated by spaces and followed by a newline.
func NewHandler ¶
NewHandler creates a Handler that writes to w with the provided Options.
func (*Handler) Enabled ¶
Enabled reports whether the handler handles records at the given level. The handler ignores records whose level is lower.
func (*Handler) Handle ¶
Handle processes the log record and writes it to the writer with appropriate formatting.
type MapOfLevel ¶ added in v1.5.0
type OptionFn ¶ added in v1.5.0
type OptionFn func(*options)
func SetLevel ¶ added in v1.5.0
SetLevel set the minimum log level to handle. By default, level INFO is set.
func SetLevelStr ¶ added in v1.5.0
func SetLevelStr(strLvl MapOfLevel) OptionFn
SetLevelStr set the handler "level to string" map. The default one is used if none specified.
func SetTimeFormat ¶ added in v1.5.0
SetTimeFormat specifies the time format for the log records. By default, nothing is reported.
func ShowSource ¶ added in v1.5.0
func ShowSource() OptionFn
ShowSource indicates whether to display the source of the log records. By default, nothing is reported.