Documentation
¶
Index ¶
- Constants
- func ConfigureChannel(name string, opts *Options)
- func Debug(msg any)
- func Debugf(format any, args ...any)
- func Error(msg any)
- func Errorf(format any, args ...any)
- func Fatal(msg any)
- func Fatalf(format any, args ...any)
- func Info(msg any)
- func Infof(format any, args ...any)
- func Init(opts ...*Options)
- func NewDfHandler(opts *Options) slog.Handler
- func NewPrettyHandler(level slog.Level, options *Options) slog.Handler
- func NewPrettyHandlerWithChannel(level slog.Level, options *Options, channelName string) slog.Handler
- func RemoveChannel(name string)
- func Warn(msg any)
- func Warnf(format any, args ...any)
- type Builder
- func (b *Builder) Debug(msg any)
- func (b *Builder) Debugf(format any, args ...any)
- func (b *Builder) Error(msg any)
- func (b *Builder) Errorf(format any, args ...any)
- func (b *Builder) Fatal(msg any)
- func (b *Builder) Fatalf(format any, args ...any)
- func (b *Builder) Info(msg any)
- func (b *Builder) Infof(format any, args ...any)
- func (b *Builder) Warn(msg any)
- func (b *Builder) Warnf(format any, args ...any)
- func (b *Builder) With(key string, value any) *Builder
- type Channel
- type ChannelManager
- func (cm *ChannelManager) ConfigureChannel(name string, opts *Options)
- func (cm *ChannelManager) ConfigureDefaultChannel(opts *Options)
- func (cm *ChannelManager) GetChannel(name string) *Channel
- func (cm *ChannelManager) GetChannelLogger(name string) *slog.Logger
- func (cm *ChannelManager) GetChannelOptions(name string) *Options
- func (cm *ChannelManager) GetDefaultChannel() *Channel
- func (cm *ChannelManager) GetDefaultLogger() *slog.Logger
- func (cm *ChannelManager) GetDefaultOptions() *Options
- func (cm *ChannelManager) IsChannelConfigured(name string) bool
- func (cm *ChannelManager) ListConfiguredChannels() []string
- func (cm *ChannelManager) RemoveChannel(name string)
- type Options
- func (o *Options) Color() *Options
- func (o *Options) JSON() *Options
- func (o *Options) NoColor() *Options
- func (o *Options) Pretty() *Options
- func (o *Options) SetLevel(level slog.Level) *Options
- func (o *Options) SetOutput(w io.Writer) *Options
- func (o *Options) SetTrimPrefix(prefix string) *Options
- type PrettyHandler
Constants ¶
const ChannelKey = "channel"
Variables ¶
This section is empty.
Functions ¶
func ConfigureChannel ¶
ConfigureChannel sets a specific logger configuration for a channel
func Debug ¶ added in v0.3.1
func Debug(msg any)
Debug logs a debug message using the default logger
func Error ¶ added in v0.3.1
func Error(msg any)
Error logs an error message using the default logger
func Fatal ¶ added in v0.3.1
func Fatal(msg any)
Fatal logs a fatal error message using the default logger and exits the program
func Fatalf ¶ added in v0.3.1
Fatalf logs a formatted fatal error message using the default logger and exits the program
func Init ¶
func Init(opts ...*Options)
Init initializes the logging system with the provided options. if no options are provided, uses default options.
func NewDfHandler ¶
NewDfHandler creates a handler that supports both pretty and JSON modes
func NewPrettyHandler ¶
NewPrettyHandler creates a new pretty handler - direct port from pfxlog
func NewPrettyHandlerWithChannel ¶
func NewPrettyHandlerWithChannel(level slog.Level, options *Options, channelName string) slog.Handler
NewPrettyHandlerWithChannel creates a pretty handler with an optional channel name
func RemoveChannel ¶
func RemoveChannel(name string)
RemoveChannel removes a channel configuration, causing it to revert to defaults
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder provides a fluent API for contextual logging, allowing attributes to be added before logging messages. preserves pfxlog's builder pattern semantics.
func ChannelLog ¶
ChannelLog creates a logger with a specific channel attribute for categorizing log entries
func Log ¶
func Log() *Builder
Log returns a general logger builder for adding contextual attributes
func (*Builder) Fatal ¶
Fatal logs a fatal error message with the accumulated attributes and exits the program
func (*Builder) Fatalf ¶
Fatalf logs a formatted fatal error message with the accumulated attributes and exits the program
type ChannelManager ¶
type ChannelManager struct {
// contains filtered or unexported fields
}
ChannelManager manages per-channel logging with independent destinations
func NewChannelManager ¶
func NewChannelManager(defaultOpts *Options) *ChannelManager
NewChannelManager creates a new channel log manager
func (*ChannelManager) ConfigureChannel ¶
func (cm *ChannelManager) ConfigureChannel(name string, opts *Options)
ConfigureChannel sets a specific logger configuration for a channel
func (*ChannelManager) ConfigureDefaultChannel ¶
func (cm *ChannelManager) ConfigureDefaultChannel(opts *Options)
ConfigureDefaultChannel updates the default options and recreates the default logger
func (*ChannelManager) GetChannel ¶
func (cm *ChannelManager) GetChannel(name string) *Channel
GetChannel returns the full Channel for a specific channel Returns nil if the channel is not configured
func (*ChannelManager) GetChannelLogger ¶
func (cm *ChannelManager) GetChannelLogger(name string) *slog.Logger
GetChannelLogger returns a logger for the specified channel
func (*ChannelManager) GetChannelOptions ¶
func (cm *ChannelManager) GetChannelOptions(name string) *Options
GetChannelOptions returns a copy of the options for a specific channel Returns nil if the channel is not configured
func (*ChannelManager) GetDefaultChannel ¶
func (cm *ChannelManager) GetDefaultChannel() *Channel
GetDefaultChannel returns a copy of the default log channel
func (*ChannelManager) GetDefaultLogger ¶
func (cm *ChannelManager) GetDefaultLogger() *slog.Logger
GetDefaultLogger returns the default logger
func (*ChannelManager) GetDefaultOptions ¶
func (cm *ChannelManager) GetDefaultOptions() *Options
GetDefaultOptions returns a copy of the default log options
func (*ChannelManager) IsChannelConfigured ¶
func (cm *ChannelManager) IsChannelConfigured(name string) bool
IsChannelConfigured returns true if the channel has been explicitly configured
func (*ChannelManager) ListConfiguredChannels ¶
func (cm *ChannelManager) ListConfiguredChannels() []string
ListConfiguredChannels returns the names of all configured channels
func (*ChannelManager) RemoveChannel ¶
func (cm *ChannelManager) RemoveChannel(name string)
RemoveChannel removes a channel configuration, causing it to revert to defaults
type Options ¶
type Options struct {
Level slog.Level
UseJSON bool
UseColor bool
AbsoluteTime bool
StartTimestamp time.Time
TimestampFormat string
TrimPrefix string
Output io.Writer // output destination, defaults to os.Stdout
CustomHandler slog.Handler
// level labels
ErrorLabel string
WarningLabel string
InfoLabel string
DebugLabel string
// colors
TimestampColor string
FunctionColor string
ChannelColor string
FieldsColor string
DefaultFgColor string // used for resetting colors
ErrorColor string
WarningColor string
InfoColor string
DebugColor string
}
Options configures the df logging system, compatible with pfxlog.Options
func DefaultOptions ¶
func DefaultOptions() *Options
DefaultOptions creates a default configuration with sensible defaults
func (*Options) SetTrimPrefix ¶
SetTrimPrefix sets the function trim prefix
type PrettyHandler ¶
type PrettyHandler struct {
// contains filtered or unexported fields
}
PrettyHandler is a direct port of pfxlog's PrettyHandler for df
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
dlpretty
command
|
|
|
examples
|
|
|
dl_01_hello_world
command
|
|
|
dl_02_channels
command
|
|
|
dl_03_formatters
command
|