Documentation
¶
Overview ¶
Package logger provides a structured logging interface for MALT. It wraps go.uber.org/zap for high-performance logging with support for performance analysis and debugging.
Index ¶
- Variables
- func Close() error
- func Debug(msg string, fields ...Field)
- func Error(msg string, fields ...Field)
- func Fatal(msg string, fields ...Field)
- func Info(msg string, fields ...Field)
- func Init(cfg Config) error
- func InitDevelopment() error
- func InitProduction() error
- func Named(name string) *zap.SugaredLogger
- func SetLevel(level Level)
- func Sync() error
- func Warn(msg string, fields ...Field)
- func With(fields ...Field) *zap.SugaredLogger
- type Config
- type Field
- type Level
Constants ¶
This section is empty.
Variables ¶
var ( DebugLevel = zapcore.DebugLevel InfoLevel = zapcore.InfoLevel WarnLevel = zapcore.WarnLevel ErrorLevel = zapcore.ErrorLevel )
Log levels.
var ( String = zap.String Int = zap.Int Int64 = zap.Int64 Float64 = zap.Float64 Bool = zap.Bool Err = zap.Error // Use Err for zap.Error field Any = zap.Any )
Common field constructors.
var Logger *zap.SugaredLogger
Logger is the global logger instance.
Functions ¶
func Close ¶
func Close() error
Close closes the logger and releases any file handles. This should be called when the logger is no longer needed, especially important for tests using temporary directories to avoid file locking issues on Windows.
func InitDevelopment ¶
func InitDevelopment() error
InitDevelopment initializes a development logger.
func With ¶
func With(fields ...Field) *zap.SugaredLogger
With returns a logger with additional fields.
Types ¶
type Config ¶
type Config struct {
// Level is the minimum log level.
Level Level
// Development mode uses human-friendly output.
Development bool
// OutputPaths are paths to write logs to.
// Defaults to ["stdout"].
OutputPaths []string
// ErrorOutputPaths are paths to write internal errors to.
// Defaults to ["stderr"].
ErrorOutputPaths []string
}
Config holds logger configuration.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the default logger configuration.
func DevelopmentConfig ¶
func DevelopmentConfig() Config
DevelopmentConfig returns a development-friendly configuration.