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 Options ¶
type Options struct { // TimeFormat specifies the time format for log records. // Empty string will remove the time in records. TimeFormat string // Level is the minimum log level to handle. Level slog.Level // ShowSource indicates whether to display the source of log records. ShowSource bool }
Options defines the options for configuring the Handler.
Click to show internal directories.
Click to hide internal directories.