Documentation
¶
Index ¶
- type ConsoleLogger
- func (l *ConsoleLogger) Debug(msg string, fields ...Field)
- func (l *ConsoleLogger) Error(msg string, fields ...Field)
- func (l *ConsoleLogger) Fatal(msg string, fields ...Field)
- func (l *ConsoleLogger) Info(msg string, fields ...Field)
- func (l *ConsoleLogger) Panic(msg string, fields ...Field)
- func (l *ConsoleLogger) Warn(msg string, fields ...Field)
- func (l *ConsoleLogger) WithContext(ctx context.Context) Logger
- func (l *ConsoleLogger) WithFields(fields ...Field) Logger
- type Field
- func Any(key string, value any) Field
- func Bool(key string, value bool) Field
- func Duration(key string, value time.Duration) Field
- func Error(err error) Field
- func Float64(key string, value float64) Field
- func Int(key string, value int) Field
- func Int64(key string, value int64) Field
- func String(key, value string) Field
- func Time(key string, value time.Time) Field
- type FileLogger
- func (l *FileLogger) Close() error
- func (l *FileLogger) Debug(msg string, fields ...Field)
- func (l *FileLogger) Error(msg string, fields ...Field)
- func (l *FileLogger) Fatal(msg string, fields ...Field)
- func (l *FileLogger) Info(msg string, fields ...Field)
- func (l *FileLogger) Panic(msg string, fields ...Field)
- func (l *FileLogger) Warn(msg string, fields ...Field)
- func (l *FileLogger) WithContext(ctx context.Context) Logger
- func (l *FileLogger) WithFields(fields ...Field) Logger
- type FileLoggerConfig
- type LogLevel
- type Logger
- type MultiLogger
- func (m *MultiLogger) Debug(msg string, fields ...Field)
- func (m *MultiLogger) Error(msg string, fields ...Field)
- func (m *MultiLogger) Fatal(msg string, fields ...Field)
- func (m *MultiLogger) Info(msg string, fields ...Field)
- func (m *MultiLogger) Panic(msg string, fields ...Field)
- func (m *MultiLogger) Warn(msg string, fields ...Field)
- func (m *MultiLogger) WithContext(ctx context.Context) Logger
- func (m *MultiLogger) WithFields(fields ...Field) Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConsoleLogger ¶
type ConsoleLogger struct {
// contains filtered or unexported fields
}
ConsoleLogger implements Logger interface for console output
func (*ConsoleLogger) Debug ¶
func (l *ConsoleLogger) Debug(msg string, fields ...Field)
Debug logs a debug message
func (*ConsoleLogger) Error ¶
func (l *ConsoleLogger) Error(msg string, fields ...Field)
Error logs an error message
func (*ConsoleLogger) Fatal ¶
func (l *ConsoleLogger) Fatal(msg string, fields ...Field)
Fatal logs a fatal message and exits
func (*ConsoleLogger) Info ¶
func (l *ConsoleLogger) Info(msg string, fields ...Field)
Info logs an info message
func (*ConsoleLogger) Panic ¶
func (l *ConsoleLogger) Panic(msg string, fields ...Field)
Panic logs a panic message and panics
func (*ConsoleLogger) Warn ¶
func (l *ConsoleLogger) Warn(msg string, fields ...Field)
Warn logs a warning message
func (*ConsoleLogger) WithContext ¶
func (l *ConsoleLogger) WithContext(ctx context.Context) Logger
WithContext creates a new logger with context (for future use with request tracing)
func (*ConsoleLogger) WithFields ¶
func (l *ConsoleLogger) WithFields(fields ...Field) Logger
WithFields creates a new logger with additional context fields
type Field ¶
Field represents a key-value pair for structured logging
type FileLogger ¶
type FileLogger struct {
// contains filtered or unexported fields
}
FileLogger implements Logger interface for file output with rotation
func (*FileLogger) Close ¶
func (l *FileLogger) Close() error
Close closes the file logger and flushes any remaining logs
func (*FileLogger) Debug ¶
func (l *FileLogger) Debug(msg string, fields ...Field)
Debug logs a debug message
func (*FileLogger) Error ¶
func (l *FileLogger) Error(msg string, fields ...Field)
Error logs an error message
func (*FileLogger) Fatal ¶
func (l *FileLogger) Fatal(msg string, fields ...Field)
Fatal logs a fatal message and exits
func (*FileLogger) Info ¶
func (l *FileLogger) Info(msg string, fields ...Field)
Info logs an info message
func (*FileLogger) Panic ¶
func (l *FileLogger) Panic(msg string, fields ...Field)
Panic logs a panic message and panics
func (*FileLogger) Warn ¶
func (l *FileLogger) Warn(msg string, fields ...Field)
Warn logs a warning message
func (*FileLogger) WithContext ¶
func (l *FileLogger) WithContext(ctx context.Context) Logger
WithContext creates a new logger with context
func (*FileLogger) WithFields ¶
func (l *FileLogger) WithFields(fields ...Field) Logger
WithFields creates a new logger with additional context fields
type FileLoggerConfig ¶
type FileLoggerConfig struct {
Filename string
MaxSize int // megabytes
MaxBackups int // number of backups
MaxAge int // days
Compress bool // compress rotated files
JsonFormat bool // use JSON format
}
FileLoggerConfig contains configuration for file logging with rotation
type Logger ¶
type Logger interface {
Debug(msg string, fields ...Field)
Info(msg string, fields ...Field)
Warn(msg string, fields ...Field)
Error(msg string, fields ...Field)
Fatal(msg string, fields ...Field)
Panic(msg string, fields ...Field)
WithFields(fields ...Field) Logger
WithContext(ctx context.Context) Logger
}
Logger interface defines the logging contract This interface is framework-agnostic and can be implemented by any logger
func NewConsoleLogger ¶
NewConsoleLogger creates a new console logger with specified level
func NewConsoleLoggerWithWriter ¶
NewConsoleLoggerWithWriter creates a console logger with custom writer and colorization
func NewFileLogger ¶
func NewFileLogger(level LogLevel, config *FileLoggerConfig) Logger
NewFileLogger creates a new file logger with rotation
func NewMultiLogger ¶
NewMultiLogger creates a new multi-logger that forwards to multiple logger implementations
type MultiLogger ¶
type MultiLogger struct {
// contains filtered or unexported fields
}
MultiLogger implements Logger interface and forwards logs to multiple loggers This allows combining console and file logging or any other logger implementations
func (*MultiLogger) Debug ¶
func (m *MultiLogger) Debug(msg string, fields ...Field)
Debug logs a debug message to all underlying loggers
func (*MultiLogger) Error ¶
func (m *MultiLogger) Error(msg string, fields ...Field)
Error logs an error message to all underlying loggers
func (*MultiLogger) Fatal ¶
func (m *MultiLogger) Fatal(msg string, fields ...Field)
Fatal logs a fatal message to all underlying loggers and exits
func (*MultiLogger) Info ¶
func (m *MultiLogger) Info(msg string, fields ...Field)
Info logs an info message to all underlying loggers
func (*MultiLogger) Panic ¶
func (m *MultiLogger) Panic(msg string, fields ...Field)
Panic logs a panic message to all underlying loggers and panics
func (*MultiLogger) Warn ¶
func (m *MultiLogger) Warn(msg string, fields ...Field)
Warn logs a warning message to all underlying loggers
func (*MultiLogger) WithContext ¶
func (m *MultiLogger) WithContext(ctx context.Context) Logger
WithContext creates a new multi-logger with context
func (*MultiLogger) WithFields ¶
func (m *MultiLogger) WithFields(fields ...Field) Logger
WithFields creates a new multi-logger with additional context fields