Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LogConfig ¶ added in v0.9.5
type LogConfig struct {
// Driver specifies the log driver: "console" or "file".
Driver string
// Config holds driver-specific options (e.g., "path" for file driver).
Config map[string]any
}
LogConfig holds configuration for creating a Logger instance.
func LogConfigFromEnv ¶ added in v0.9.5
func LogConfigFromEnv() LogConfig
LogConfigFromEnv builds a LogConfig from environment variables. It reads LOG_DRIVER, LOG_PATH, LOG_LEVEL, and LOG_FORMAT.
type Logger ¶
type Logger interface {
Debug(msg string, kvs ...any)
Info(msg string, kvs ...any)
Warn(msg string, kvs ...any)
Error(msg string, kvs ...any)
Fatal(msg string, kvs ...any)
}
Logger defines the interface for all log implementations
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles multiple logger channels for advanced logging scenarios. Each channel can have its own driver configuration (file, console, stack, null)
func NewManager ¶
func NewManager(cfg config.LoggingConfig) *Manager
NewManager creates a new logger manager with the given configuration. The manager allows different log channels with independent drivers and settings
type NullLogger ¶
type NullLogger struct{}
NullLogger discards all log messages without any output. Useful for testing or disabling logging for specific channels
func NewNullLogger ¶
func NewNullLogger() *NullLogger
NewNullLogger creates a logger that silently discards all messages. No output is produced regardless of log level
func (*NullLogger) Debug ¶
func (n *NullLogger) Debug(msg string, kvs ...any)
func (*NullLogger) Error ¶
func (n *NullLogger) Error(msg string, kvs ...any)
func (*NullLogger) Fatal ¶
func (n *NullLogger) Fatal(msg string, kvs ...any)
func (*NullLogger) Info ¶
func (n *NullLogger) Info(msg string, kvs ...any)
func (*NullLogger) Warn ¶
func (n *NullLogger) Warn(msg string, kvs ...any)
type StackLogger ¶
type StackLogger struct {
// contains filtered or unexported fields
}
StackLogger logs to multiple loggers simultaneously. Useful for logging to multiple destinations (e.g., file and console)
func NewStackLogger ¶
func NewStackLogger(loggers ...Logger) *StackLogger
NewStackLogger creates a logger that writes to multiple loggers. All provided loggers will receive the same log messages
func (*StackLogger) Debug ¶
func (s *StackLogger) Debug(msg string, kvs ...any)
Debug logs a debug message to all configured loggers
func (*StackLogger) Error ¶
func (s *StackLogger) Error(msg string, kvs ...any)
Error logs an error message to all configured loggers
func (*StackLogger) Fatal ¶
func (s *StackLogger) Fatal(msg string, kvs ...any)
Fatal logs a fatal message to all configured loggers
func (*StackLogger) Info ¶
func (s *StackLogger) Info(msg string, kvs ...any)
Info logs an info message to all configured loggers
func (*StackLogger) Warn ¶
func (s *StackLogger) Warn(msg string, kvs ...any)
Warn logs a warning message to all configured loggers