Documentation
¶
Overview ¶
Package slogpretty provides a custom slog.Handler that formats log records with colorized levels, indented JSON fields, and timestamp prefixes for human-readable output.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PrettyHandler ¶
PrettyHandler is a slog.Handler implementation that outputs logs in a human-friendly format with ANSI color codes and indented JSON fields.
func (*PrettyHandler) Handle ¶
Handle processes a log record by formatting it with colorized level, timestamp, message, and pretty-printed JSON attributes. Implements slog.Handler.
type PrettyHandlerOptions ¶
type PrettyHandlerOptions struct {
SlogOpts *slog.HandlerOptions
}
PrettyHandlerOptions configures the behavior of the PrettyHandler. It embeds slog.HandlerOptions to inherit standard handler configurations.
func (PrettyHandlerOptions) NewPrettyHandler ¶
func (opts PrettyHandlerOptions) NewPrettyHandler( out io.Writer, ) *PrettyHandler
NewPrettyHandler creates a new PrettyHandler that writes to the given output. It combines colorized level prefixes, timestamp, message, and indented JSON attributes for improved readability.