Documentation
¶
Overview ¶
Package logger provides structured logging with levels.
Index ¶
- type BufferedConfig
- type Level
- type Logger
- func (l *Logger) Debug(msg string, fields ...map[string]interface{})
- func (l *Logger) Error(msg string, fields ...map[string]interface{})
- func (l *Logger) Fatal(msg string, fields ...map[string]interface{})
- func (l *Logger) FlushForTesting()
- func (l *Logger) Info(msg string, fields ...map[string]interface{})
- func (l *Logger) SetLevel(level Level)
- func (l *Logger) SetOutputForTesting(w io.Writer)
- func (l *Logger) Warn(msg string, fields ...map[string]interface{})
- func (l *Logger) WithPrefix(prefix string) *Logger
- type LoggerDeps
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BufferedConfig ¶
type BufferedConfig struct {
FlushInterval time.Duration // default 500ms
BufferSize int // default 50 entries
MaxFileSize int64 // default 50 MB; 0 = no rotation
MaxBackups int // default 2
FilePath string // if empty, uses direct writer
}
BufferedConfig configures the buffered writer.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a structured logger.
func Default ¶
func Default() *Logger
Default returns a default logger writing to stderr at Info level.
func NewWithDeps ¶
func NewWithDeps(deps LoggerDeps) *Logger
NewWithDeps creates a new logger from a deps struct. Zero-value fields are replaced with production defaults. Note: Level zero-value is Debug (iota=0), so use Default() for Info-level logger.
func (*Logger) FlushForTesting ¶
func (l *Logger) FlushForTesting()
FlushForTesting synchronously flushes any buffered output. Test-only; not for production use.
func (*Logger) SetOutputForTesting ¶
SetOutputForTesting replaces the logger's output writer. Test-only; not for production use.
func (*Logger) WithPrefix ¶
WithPrefix returns a new logger with the given prefix.
type LoggerDeps ¶
LoggerDeps holds configurable dependencies for Logger. Zero values are filled with production defaults by NewWithDeps.