Documentation
¶
Index ¶
- func Init(cfg Config)
- func LogDebug(msg string, args ...interface{})
- func LogDebugWithFields(msg string, fields ...zap.Field)
- func LogError(msg string, args ...interface{})
- func LogErrorWithFields(msg string, fields ...zap.Field)
- func LogFatal(msg string, args ...interface{})
- func LogFatalWithFields(msg string, fields ...zap.Field)
- func LogInfo(msg string, args ...interface{})
- func LogInfoWithFields(msg string, fields ...zap.Field)
- func LogWarn(msg string, args ...interface{})
- func LogWarnWithFields(msg string, fields ...zap.Field)
- func NewFancyEncoder(cfg zapcore.EncoderConfig) zapcore.Encoder
- type Config
- type FancyEncoder
- func (e *FancyEncoder) AddArray(key string, marshaler zapcore.ArrayMarshaler) error
- func (e *FancyEncoder) AddBinary(key string, value []byte)
- func (e *FancyEncoder) AddBool(key string, value bool)
- func (e *FancyEncoder) AddByteString(key string, value []byte)
- func (e *FancyEncoder) AddComplex64(key string, value complex64)
- func (e *FancyEncoder) AddComplex128(key string, value complex128)
- func (e *FancyEncoder) AddDuration(key string, value time.Duration)
- func (e *FancyEncoder) AddFloat32(key string, value float32)
- func (e *FancyEncoder) AddFloat64(key string, value float64)
- func (e *FancyEncoder) AddInt(key string, value int)
- func (e *FancyEncoder) AddInt8(key string, value int8)
- func (e *FancyEncoder) AddInt16(key string, value int16)
- func (e *FancyEncoder) AddInt32(key string, value int32)
- func (e *FancyEncoder) AddInt64(key string, value int64)
- func (e *FancyEncoder) AddObject(key string, marshaler zapcore.ObjectMarshaler) error
- func (e *FancyEncoder) AddReflected(key string, value interface{}) error
- func (e *FancyEncoder) AddString(key string, value string)
- func (e *FancyEncoder) AddTime(key string, value time.Time)
- func (e *FancyEncoder) AddUint(key string, value uint)
- func (e *FancyEncoder) AddUint8(key string, value uint8)
- func (e *FancyEncoder) AddUint16(key string, value uint16)
- func (e *FancyEncoder) AddUint32(key string, value uint32)
- func (e *FancyEncoder) AddUint64(key string, value uint64)
- func (e *FancyEncoder) AddUintptr(key string, value uintptr)
- func (e *FancyEncoder) Clone() zapcore.Encoder
- func (e *FancyEncoder) EncodeEntry(entry zapcore.Entry, fields []zapcore.Field) (*buffer.Buffer, error)
- func (e *FancyEncoder) OpenNamespace(key string)
- type Logger
- func (l *Logger) Debug(msg string, args ...interface{})
- func (l *Logger) DebugWithFields(msg string, fields ...zap.Field)
- func (l *Logger) Error(msg string, args ...interface{})
- func (l *Logger) ErrorWithFields(msg string, fields ...zap.Field)
- func (l *Logger) Fatal(msg string, args ...interface{})
- func (l *Logger) FatalWithFields(msg string, fields ...zap.Field)
- func (l *Logger) Info(msg string, args ...interface{})
- func (l *Logger) InfoWithFields(msg string, fields ...zap.Field)
- func (l *Logger) Warn(msg string, args ...interface{})
- func (l *Logger) WarnWithFields(msg string, fields ...zap.Field)
- type RotatingFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LogDebug ¶
func LogDebug(msg string, args ...interface{})
LogDebug logs at Debug level using global logger
func LogDebugWithFields ¶
LogDebugWithFields logs at Debug level with structured fields using global logger
func LogError ¶
func LogError(msg string, args ...interface{})
LogError logs at Error level using global logger
func LogErrorWithFields ¶
LogErrorWithFields logs at Error level with structured fields using global logger
func LogFatal ¶
func LogFatal(msg string, args ...interface{})
LogFatal logs at Fatal level using global logger
func LogFatalWithFields ¶
LogFatalWithFields logs at Fatal level with structured fields using global logger
func LogInfo ¶
func LogInfo(msg string, args ...interface{})
LogInfo logs at Info level using global logger
func LogInfoWithFields ¶
LogInfoWithFields logs at Info level with structured fields using global logger
func LogWarn ¶
func LogWarn(msg string, args ...interface{})
LogWarn logs at Warn level using global logger
func LogWarnWithFields ¶
LogWarnWithFields logs at Warn level with structured fields using global logger
func NewFancyEncoder ¶
func NewFancyEncoder(cfg zapcore.EncoderConfig) zapcore.Encoder
Types ¶
type Config ¶
type Config struct {
ServiceName string
Level zapcore.Level
Output zapcore.WriteSyncer // default os.Stdout
Format string // "console" or "json", default "console"
File string // log file path, if set, writes to file instead of Output
LogPath string // directory for daily rotating logs
LogPrefix string // prefix for log files (default "log")
FileFormat string // "console" or "json" for file output, default "json"
}
type FancyEncoder ¶
type FancyEncoder struct {
// contains filtered or unexported fields
}
func (*FancyEncoder) AddArray ¶
func (e *FancyEncoder) AddArray(key string, marshaler zapcore.ArrayMarshaler) error
func (*FancyEncoder) AddBinary ¶
func (e *FancyEncoder) AddBinary(key string, value []byte)
func (*FancyEncoder) AddBool ¶
func (e *FancyEncoder) AddBool(key string, value bool)
func (*FancyEncoder) AddByteString ¶
func (e *FancyEncoder) AddByteString(key string, value []byte)
func (*FancyEncoder) AddComplex64 ¶
func (e *FancyEncoder) AddComplex64(key string, value complex64)
func (*FancyEncoder) AddComplex128 ¶
func (e *FancyEncoder) AddComplex128(key string, value complex128)
func (*FancyEncoder) AddDuration ¶
func (e *FancyEncoder) AddDuration(key string, value time.Duration)
func (*FancyEncoder) AddFloat32 ¶
func (e *FancyEncoder) AddFloat32(key string, value float32)
func (*FancyEncoder) AddFloat64 ¶
func (e *FancyEncoder) AddFloat64(key string, value float64)
func (*FancyEncoder) AddInt ¶
func (e *FancyEncoder) AddInt(key string, value int)
func (*FancyEncoder) AddInt8 ¶
func (e *FancyEncoder) AddInt8(key string, value int8)
func (*FancyEncoder) AddInt16 ¶
func (e *FancyEncoder) AddInt16(key string, value int16)
func (*FancyEncoder) AddInt32 ¶
func (e *FancyEncoder) AddInt32(key string, value int32)
func (*FancyEncoder) AddInt64 ¶
func (e *FancyEncoder) AddInt64(key string, value int64)
func (*FancyEncoder) AddObject ¶
func (e *FancyEncoder) AddObject(key string, marshaler zapcore.ObjectMarshaler) error
func (*FancyEncoder) AddReflected ¶
func (e *FancyEncoder) AddReflected(key string, value interface{}) error
func (*FancyEncoder) AddString ¶
func (e *FancyEncoder) AddString(key string, value string)
func (*FancyEncoder) AddUint ¶
func (e *FancyEncoder) AddUint(key string, value uint)
func (*FancyEncoder) AddUint8 ¶
func (e *FancyEncoder) AddUint8(key string, value uint8)
func (*FancyEncoder) AddUint16 ¶
func (e *FancyEncoder) AddUint16(key string, value uint16)
func (*FancyEncoder) AddUint32 ¶
func (e *FancyEncoder) AddUint32(key string, value uint32)
func (*FancyEncoder) AddUint64 ¶
func (e *FancyEncoder) AddUint64(key string, value uint64)
func (*FancyEncoder) AddUintptr ¶
func (e *FancyEncoder) AddUintptr(key string, value uintptr)
func (*FancyEncoder) Clone ¶
func (e *FancyEncoder) Clone() zapcore.Encoder
func (*FancyEncoder) EncodeEntry ¶
func (e *FancyEncoder) EncodeEntry(entry zapcore.Entry, fields []zapcore.Field) (*buffer.Buffer, error)
EncodeEntry encodes a log entry into a buffer with a custom console format. Format: timestamp LEVEL [logger] caller message fields_json
func (*FancyEncoder) OpenNamespace ¶
func (e *FancyEncoder) OpenNamespace(key string)
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func MustNewLogger ¶
MustNewLogger creates a new logger instance and panics on error
func (*Logger) DebugWithFields ¶
DebugWithFields logs at Debug level with structured fields
func (*Logger) ErrorWithFields ¶
ErrorWithFields logs at Error level with structured fields
func (*Logger) FatalWithFields ¶
FatalWithFields logs at Fatal level with structured fields
func (*Logger) InfoWithFields ¶
InfoWithFields logs at Info level with structured fields
type RotatingFile ¶
type RotatingFile struct {
// contains filtered or unexported fields
}
func NewRotatingFile ¶
func NewRotatingFile(dir, prefix string) *RotatingFile
func (*RotatingFile) Sync ¶
func (r *RotatingFile) Sync() error