Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CLI ¶
type CLI struct { // Colorize indicates whether colors will be used // in log output. Colorize bool // Out is where log output will be written. Out io.Writer Options // contains filtered or unexported fields }
CLI is an slog handler for command-line tools where users will view and read the logs throughout the application's execution.
func (*CLI) Enabled ¶
Enabled reports whether the handler handles records at the given level. The handler ignores records whose level is lower.
func (*CLI) Handle ¶
Handle formats the given log/slog.Record as a human-readable string on a single line.
type Options ¶
type Options struct { // TimeFormat represents the format of the timestamp // provided by the [Pretty] logger. TimeFormat string // Level is the log level above which the handler will // handle records. Level slog.Level // ShowCaller indicates whether the caller that created the // record should be provided in the output ShowCaller bool // ForceColors prevents checking whether a handler outputs // to a valid tty and always enables colors if set to true. ForceColors bool }
Options represents common options for slog handlers in this package.
type Pretty ¶
type Pretty struct { // Colorize indicates whether colors will be used // in log output. Colorize bool // Out is where log output will be written. Out io.Writer Options // contains filtered or unexported fields }
Pretty is an slog handler with a human-readable output
func NewPretty ¶
NewPretty creates and returns a new Pretty handler. If opts doesn't specify a time format, time.Kitchen will be used.
func (*Pretty) Enabled ¶
Enabled reports whether the handler handles records at the given level. The handler ignores records whose level is lower.
func (*Pretty) Handle ¶
Handle formats the given log/slog.Record as a human-readable string on a single line.