Documentation ¶
Overview ¶
Package clilog provides a slog.Handler for command line tools.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CLIHandler ¶
type CLIHandler struct {
// contains filtered or unexported fields
}
CLIHandler implements a slog.Handler for command line tools. The output format of CLIHandler is designed to be human readable.
func NewCLIHandler ¶
func NewCLIHandler(w io.Writer, opts *HandlerOptions) *CLIHandler
NewCLIHandler returns a new CLIHandler.
func (*CLIHandler) Enabled ¶
Enabled reports whether the handler handles records at the given level. The handler ignores records whose level is lower.
type HandlerOptions ¶
type HandlerOptions struct { // AddSource causes the handler to output the source code // position of the log statement. AddSource bool // Level reports the minimum record level that will be logged. // The handler discards records with lower levels. If Level is // nil, the handler assumes LevelInfo. The handler calls // Level.Level for each record processed; to adjust the // minimum level dynamically, use a LevelVar. Level slog.Leveler }
HandlerOptions are options for a CLIHandler. A zero HandlerOptions consists entirely of default values.
Click to show internal directories.
Click to hide internal directories.