Documentation
¶
Index ¶
Constants ¶
View Source
const ( LevelTrace = slog.LevelDebug - 4 LevelFatal = slog.LevelError + 4 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type PrettyTextHandler ¶
type PrettyTextHandler struct {
// contains filtered or unexported fields
}
func NewPrettyTextHandler ¶
func NewPrettyTextHandler(out io.Writer, opts *PrettyTextOptions) *PrettyTextHandler
type PrettyTextOptions ¶
type PrettyTextOptions struct {
Level slog.Leveler
// AddSource adds slog.SourceKey attr, same idea as slog.HandlerOptions.AddSource.
AddSource bool
// ReplaceAttr is called to rewrite or drop attributes.
//
// To drop an attr, return slog.Attr{}.
//
// Built-in attrs passed to ReplaceAttr:
// - slog.TimeKey
// - slog.LevelKey
// - slog.SourceKey, when AddSource is true
//
// Message is not passed through ReplaceAttr because this handler prints it
// as the fixed main log text.
ReplaceAttr func(groups []string, attr slog.Attr) slog.Attr
// TimeFormat controls timestamp rendering.
// Default: "2006-01-02 15:04:05".
TimeFormat string
// MessageWidth controls the padded message column.
// Default: 34.
MessageWidth int
}
Click to show internal directories.
Click to hide internal directories.