Documentation
¶
Index ¶
- func Debug(ctx context.Context, msg string, fields ...Field)
- func Debugf(msg string, fields ...Field)
- func Enabled(level Level) bool
- func Error(ctx context.Context, msg string, fields ...Field)
- func Errorf(msg string, fields ...Field)
- func Fatal(ctx context.Context, msg string, fields ...Field)
- func Info(ctx context.Context, msg string, fields ...Field)
- func Infof(msg string, fields ...Field)
- func InitGlobalLogger(config *Config) error
- func SetGlobalLogger(logger Logger)
- func Sync() error
- func ToZapFields(fields []Field) []zap.Field
- func Warn(ctx context.Context, msg string, fields ...Field)
- func Warnf(msg string, fields ...Field)
- type Config
- type Field
- func Any(key string, val interface{}) Field
- func Bool(key string, val bool) Field
- func Duration(key string, val time.Duration) Field
- func Err(err error) Field
- func Int(key string, val int) Field
- func Int64(key string, val int64) Field
- func String(key, val string) Field
- func Time(key string, val time.Time) Field
- type Level
- type Logger
- type NoOpLogger
- func (l *NoOpLogger) DPanic(ctx context.Context, msg string, fields ...Field)
- func (l *NoOpLogger) Debug(ctx context.Context, msg string, fields ...Field)
- func (l *NoOpLogger) Debugf(msg string, fields ...Field)
- func (l *NoOpLogger) Enabled(level Level) bool
- func (l *NoOpLogger) Error(ctx context.Context, msg string, fields ...Field)
- func (l *NoOpLogger) Errorf(msg string, fields ...Field)
- func (l *NoOpLogger) Fatal(ctx context.Context, msg string, fields ...Field)
- func (l *NoOpLogger) Info(ctx context.Context, msg string, fields ...Field)
- func (l *NoOpLogger) Infof(msg string, fields ...Field)
- func (l *NoOpLogger) Panic(ctx context.Context, msg string, fields ...Field)
- func (l *NoOpLogger) Sync() error
- func (l *NoOpLogger) Warn(ctx context.Context, msg string, fields ...Field)
- func (l *NoOpLogger) Warnf(msg string, fields ...Field)
- func (l *NoOpLogger) WithError(err error) Logger
- func (l *NoOpLogger) WithField(key string, value interface{}) Logger
- func (l *NoOpLogger) WithFields(fields map[string]interface{}) Logger
- type RotationConfig
- type ZapLoggerImpl
- func (l *ZapLoggerImpl) DPanic(ctx context.Context, msg string, fields ...Field)
- func (l *ZapLoggerImpl) Debug(ctx context.Context, msg string, fields ...Field)
- func (l *ZapLoggerImpl) Debugf(msg string, fields ...Field)
- func (l *ZapLoggerImpl) Enabled(level Level) bool
- func (l *ZapLoggerImpl) Error(ctx context.Context, msg string, fields ...Field)
- func (l *ZapLoggerImpl) Errorf(msg string, fields ...Field)
- func (l *ZapLoggerImpl) Fatal(ctx context.Context, msg string, fields ...Field)
- func (l *ZapLoggerImpl) Info(ctx context.Context, msg string, fields ...Field)
- func (l *ZapLoggerImpl) Infof(msg string, fields ...Field)
- func (l *ZapLoggerImpl) Panic(ctx context.Context, msg string, fields ...Field)
- func (l *ZapLoggerImpl) Sync() error
- func (l *ZapLoggerImpl) Warn(ctx context.Context, msg string, fields ...Field)
- func (l *ZapLoggerImpl) Warnf(msg string, fields ...Field)
- func (l *ZapLoggerImpl) WithError(err error) Logger
- func (l *ZapLoggerImpl) WithField(key string, value interface{}) Logger
- func (l *ZapLoggerImpl) WithFields(fields map[string]interface{}) Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitGlobalLogger ¶
InitGlobalLogger initializes the global logger instance
func SetGlobalLogger ¶
func SetGlobalLogger(logger Logger)
SetGlobalLogger sets the global logger instance directly
func ToZapFields ¶
Convert multiple fields to zap fields
Types ¶
type Config ¶
type Config struct {
Level string `yaml:"level" json:"level"`
Format string `yaml:"format" json:"format"` // json, console
DisableCaller bool `yaml:"disable_caller" json:"disable_caller"`
OutputPaths []string `yaml:"output_paths" json:"output_paths"`
Rotation *RotationConfig `yaml:"rotation" json:"rotation"`
}
Config holds the configuration for logger
func ConfigFromSettings ¶
ConfigFromSettings creates config from AIM settings
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default logger configuration
type Field ¶
type Field struct {
Key string
Value interface{}
}
Field represents a key-value pair for structured logging
type Logger ¶
type Logger interface {
Debug(ctx context.Context, msg string, fields ...Field)
Info(ctx context.Context, msg string, fields ...Field)
Warn(ctx context.Context, msg string, fields ...Field)
Error(ctx context.Context, msg string, fields ...Field)
DPanic(ctx context.Context, msg string, fields ...Field)
Panic(ctx context.Context, msg string, fields ...Field)
Fatal(ctx context.Context, msg string, fields ...Field)
// Convenience methods without context
Debugf(msg string, fields ...Field)
Infof(msg string, fields ...Field)
Warnf(msg string, fields ...Field)
Errorf(msg string, fields ...Field)
Enabled(level Level) bool
WithFields(fields map[string]interface{}) Logger
WithField(key string, value interface{}) Logger
WithError(err error) Logger
Sync() error
}
Logger defines the core logging interface
func GetGlobalLogger ¶
func GetGlobalLogger() Logger
GetGlobalLogger returns the global logger instance
func NewLoggerWithCallerSkip ¶
NewLoggerWithCallerSkip creates a new zap-based logger with caller skip
func WithFields ¶
WithFields returns a logger with additional fields
type NoOpLogger ¶
type NoOpLogger struct{}
NoOpLogger implements Logger interface with no-op operations
func (*NoOpLogger) DPanic ¶
func (l *NoOpLogger) DPanic(ctx context.Context, msg string, fields ...Field)
func (*NoOpLogger) Debug ¶
func (l *NoOpLogger) Debug(ctx context.Context, msg string, fields ...Field)
func (*NoOpLogger) Debugf ¶
func (l *NoOpLogger) Debugf(msg string, fields ...Field)
func (*NoOpLogger) Enabled ¶
func (l *NoOpLogger) Enabled(level Level) bool
func (*NoOpLogger) Error ¶
func (l *NoOpLogger) Error(ctx context.Context, msg string, fields ...Field)
func (*NoOpLogger) Errorf ¶
func (l *NoOpLogger) Errorf(msg string, fields ...Field)
func (*NoOpLogger) Fatal ¶
func (l *NoOpLogger) Fatal(ctx context.Context, msg string, fields ...Field)
func (*NoOpLogger) Info ¶
func (l *NoOpLogger) Info(ctx context.Context, msg string, fields ...Field)
func (*NoOpLogger) Infof ¶
func (l *NoOpLogger) Infof(msg string, fields ...Field)
func (*NoOpLogger) Panic ¶
func (l *NoOpLogger) Panic(ctx context.Context, msg string, fields ...Field)
func (*NoOpLogger) Sync ¶
func (l *NoOpLogger) Sync() error
func (*NoOpLogger) Warn ¶
func (l *NoOpLogger) Warn(ctx context.Context, msg string, fields ...Field)
func (*NoOpLogger) Warnf ¶
func (l *NoOpLogger) Warnf(msg string, fields ...Field)
func (*NoOpLogger) WithError ¶
func (l *NoOpLogger) WithError(err error) Logger
func (*NoOpLogger) WithField ¶
func (l *NoOpLogger) WithField(key string, value interface{}) Logger
func (*NoOpLogger) WithFields ¶
func (l *NoOpLogger) WithFields(fields map[string]interface{}) Logger
type RotationConfig ¶
type RotationConfig struct {
MaxSize int `yaml:"max_size" json:"max_size"` // MB
MaxBackups int `yaml:"max_backups" json:"max_backups"` // number of backups
MaxAge int `yaml:"max_age" json:"max_age"` // days
Compress bool `yaml:"compress" json:"compress"`
}
RotationConfig holds log rotation settings
type ZapLoggerImpl ¶
type ZapLoggerImpl struct {
// contains filtered or unexported fields
}
ZapLoggerImpl implements Logger interface using zap
func (*ZapLoggerImpl) DPanic ¶
func (l *ZapLoggerImpl) DPanic(ctx context.Context, msg string, fields ...Field)
func (*ZapLoggerImpl) Debug ¶
func (l *ZapLoggerImpl) Debug(ctx context.Context, msg string, fields ...Field)
Logger implementation methods
func (*ZapLoggerImpl) Debugf ¶
func (l *ZapLoggerImpl) Debugf(msg string, fields ...Field)
Convenience methods without context
func (*ZapLoggerImpl) Enabled ¶
func (l *ZapLoggerImpl) Enabled(level Level) bool
func (*ZapLoggerImpl) Error ¶
func (l *ZapLoggerImpl) Error(ctx context.Context, msg string, fields ...Field)
func (*ZapLoggerImpl) Errorf ¶
func (l *ZapLoggerImpl) Errorf(msg string, fields ...Field)
func (*ZapLoggerImpl) Fatal ¶
func (l *ZapLoggerImpl) Fatal(ctx context.Context, msg string, fields ...Field)
func (*ZapLoggerImpl) Info ¶
func (l *ZapLoggerImpl) Info(ctx context.Context, msg string, fields ...Field)
func (*ZapLoggerImpl) Infof ¶
func (l *ZapLoggerImpl) Infof(msg string, fields ...Field)
func (*ZapLoggerImpl) Panic ¶
func (l *ZapLoggerImpl) Panic(ctx context.Context, msg string, fields ...Field)
func (*ZapLoggerImpl) Sync ¶
func (l *ZapLoggerImpl) Sync() error
func (*ZapLoggerImpl) Warn ¶
func (l *ZapLoggerImpl) Warn(ctx context.Context, msg string, fields ...Field)
func (*ZapLoggerImpl) Warnf ¶
func (l *ZapLoggerImpl) Warnf(msg string, fields ...Field)
func (*ZapLoggerImpl) WithError ¶
func (l *ZapLoggerImpl) WithError(err error) Logger
func (*ZapLoggerImpl) WithField ¶
func (l *ZapLoggerImpl) WithField(key string, value interface{}) Logger
func (*ZapLoggerImpl) WithFields ¶
func (l *ZapLoggerImpl) WithFields(fields map[string]interface{}) Logger