Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Builder ¶ added in v1.0.3
type Builder struct {
// contains filtered or unexported fields
}
Builder implements LogBuilder to build formatted log entries.
func NewBuilder ¶ added in v1.0.3
NewBuilder creates a new Builder instance for the given record and options.
func (*Builder) WriteAttrs ¶ added in v1.0.3
func (b *Builder) WriteAttrs()
WriteAttrs appends log attributes and optional caller information.
func (*Builder) WriteLevel ¶ added in v1.0.3
func (b *Builder) WriteLevel()
WriteLevel appends the log level label with styling.
func (*Builder) WriteMessage ¶ added in v1.0.3
func (b *Builder) WriteMessage()
WriteMessage appends the main log message.
type Handler ¶
type Handler struct {
// Opts defines configuration options for log formatting and behavior.
Opts Opts
// W is the output destination for log entries.
W io.Writer
}
Handler implements slog.Handler and writes formatted log records.
func (*Handler) Handle ¶
Handle formats the record as a and writes it to stdout. Output includes timestamp, level, message, attrs, and optional caller info. The context is ignored.
type LogBuilder ¶ added in v1.0.3
type LogBuilder interface {
// WriteTime writes the formatted timestamp to the log output.
WriteTime()
// WriteLevel writes the log level representation.
WriteLevel()
// WriteMessage writes the main log message text.
WriteMessage()
// WriteAttrs writes structured attributes and optional caller info.
WriteAttrs()
// Build finalizes and returns the formatted log string.
Build() string
}
LogBuilder defines methods for constructing formatted log output.
type Opts ¶
type Opts interface {
// GetLevel returns the minimum log level for output.
GetLevel() slog.Level
// IsCallerEnabled checks if caller information should be included for the given level.
IsCallerEnabled(level slog.Level) bool
// GetPadding returns the amount of padding to apply in log messages.
GetPadding() int
// GetTimeFormat returns the time format string used for log timestamps.
GetTimeFormat() string
}
Opts defines the interface for retrieving handler configuration settings.