Documentation
¶
Index ¶
- type FileRotationConfig
- type Level
- type Logger
- type SimpleLogger
- func NewLoggerWithFile(module string, level Level, useColors bool, fileConfig *FileRotationConfig) (*SimpleLogger, error)
- func NewSimpleLogger(module string, level Level, useColors bool) *SimpleLogger
- func NewSimpleLoggerWithWriter(module string, level Level, useColors bool, writer io.Writer) *SimpleLogger
- func (l *SimpleLogger) Debug(msg string, args ...interface{})
- func (l *SimpleLogger) Error(msg string, args ...interface{})
- func (l *SimpleLogger) Fatal(msg string, args ...interface{})
- func (l *SimpleLogger) Info(msg string, args ...interface{})
- func (l *SimpleLogger) Warn(msg string, args ...interface{})
- func (l *SimpleLogger) WithModule(module string) Logger
- type TestLogger
- func (l *TestLogger) Debug(msg string, args ...interface{})
- func (l *TestLogger) Error(msg string, args ...interface{})
- func (l *TestLogger) Fatal(msg string, args ...interface{})
- func (l *TestLogger) Info(msg string, args ...interface{})
- func (l *TestLogger) Warn(msg string, args ...interface{})
- func (l *TestLogger) WithModule(module string) Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileRotationConfig ¶ added in v0.3.0
type FileRotationConfig struct {
Path string // Log file path (required)
MaxSizeMB int // Maximum size in megabytes before rotation (default: 100)
MaxBackups int // Maximum number of old log files to retain (default: 3)
MaxAge int // Maximum number of days to retain old log files (default: 28)
Compress bool // Whether to compress rotated log files (default: false)
}
FileRotationConfig contains file logging rotation settings
type Logger ¶
type Logger interface {
Debug(msg string, args ...interface{})
Info(msg string, args ...interface{})
Warn(msg string, args ...interface{})
Error(msg string, args ...interface{})
Fatal(msg string, args ...interface{})
WithModule(module string) Logger
}
Logger is the interface for logging
type SimpleLogger ¶
type SimpleLogger struct {
// contains filtered or unexported fields
}
SimpleLogger is a basic logger implementation
func NewLoggerWithFile ¶ added in v0.3.0
func NewLoggerWithFile(module string, level Level, useColors bool, fileConfig *FileRotationConfig) (*SimpleLogger, error)
NewLoggerWithFile creates a logger that writes to both console and file with rotation When file logging is enabled, colors are always disabled for file output to avoid ANSI escape codes in log files
func NewSimpleLogger ¶
func NewSimpleLogger(module string, level Level, useColors bool) *SimpleLogger
NewSimpleLogger creates a new SimpleLogger writing to stdout
func NewSimpleLoggerWithWriter ¶ added in v0.3.0
func NewSimpleLoggerWithWriter(module string, level Level, useColors bool, writer io.Writer) *SimpleLogger
NewSimpleLoggerWithWriter creates a new SimpleLogger with a custom io.Writer
func (*SimpleLogger) Debug ¶
func (l *SimpleLogger) Debug(msg string, args ...interface{})
Debug logs a debug message
func (*SimpleLogger) Error ¶
func (l *SimpleLogger) Error(msg string, args ...interface{})
Error logs an error message
func (*SimpleLogger) Fatal ¶
func (l *SimpleLogger) Fatal(msg string, args ...interface{})
Fatal logs a fatal error message and exits
func (*SimpleLogger) Info ¶
func (l *SimpleLogger) Info(msg string, args ...interface{})
Info logs an informational message
func (*SimpleLogger) Warn ¶
func (l *SimpleLogger) Warn(msg string, args ...interface{})
Warn logs a warning message
func (*SimpleLogger) WithModule ¶
func (l *SimpleLogger) WithModule(module string) Logger
WithModule creates a new logger with a hierarchical component name. If the current logger already has a component (module), the new component is appended with "/" as a separator (e.g., "proxy/middleware/session"). This allows tracing the origin of log messages through component hierarchy.
type TestLogger ¶
type TestLogger struct {
// contains filtered or unexported fields
}
TestLogger is a logger for testing that suppresses output
func NewTestLogger ¶
func NewTestLogger() *TestLogger
NewTestLogger creates a new test logger that suppresses output If you need to see logs during tests, use NewTestLoggerVerbose instead
func NewTestLoggerVerbose ¶
func NewTestLoggerVerbose(t *testing.T) *TestLogger
NewTestLoggerVerbose creates a test logger that outputs to testing.T
func (*TestLogger) Debug ¶
func (l *TestLogger) Debug(msg string, args ...interface{})
Debug logs a debug message
func (*TestLogger) Error ¶
func (l *TestLogger) Error(msg string, args ...interface{})
Error logs an error message
func (*TestLogger) Fatal ¶
func (l *TestLogger) Fatal(msg string, args ...interface{})
Fatal logs a fatal error message (but doesn't exit in tests)
func (*TestLogger) Info ¶
func (l *TestLogger) Info(msg string, args ...interface{})
Info logs an informational message
func (*TestLogger) Warn ¶
func (l *TestLogger) Warn(msg string, args ...interface{})
Warn logs a warning message
func (*TestLogger) WithModule ¶
func (l *TestLogger) WithModule(module string) Logger
WithModule creates a new logger with a hierarchical component name. If the current logger already has a component (module), the new component is appended with "/" as a separator (e.g., "proxy/middleware/session").