Documentation ¶
Index ¶
- Constants
- Variables
- func Debug(msg string, fields ...field)
- func E(err error) field
- func Error(msg string, fields ...field)
- func F(key string, value interface{}) field
- func Fatal(msg string, fields ...field)
- func FmtTime() string
- func Handler() http.Handler
- func Info(msg string, fields ...field)
- func NewFileWriter(path string) writer
- func NewJSONEncoder(cfg EncoderConfig) zapcore.Encoder
- func NewStdErrWriter() writer
- func Panic(msg string, fields ...field)
- func SetDefaultLogger(l *Logger)
- func SyncTime()
- func Warn(msg string, fields ...field)
- type EncoderConfig
- type JsonEncoder
- func (enc *JsonEncoder) AddArray(key string, arr zapcore.ArrayMarshaler) error
- func (enc *JsonEncoder) AddBinary(key string, val []byte)
- func (enc *JsonEncoder) AddBool(key string, val bool)
- func (enc *JsonEncoder) AddByteString(key string, val []byte)
- func (enc *JsonEncoder) AddComplex128(key string, val complex128)
- func (enc *JsonEncoder) AddComplex64(k string, v complex64)
- func (enc *JsonEncoder) AddDuration(key string, val time.Duration)
- func (enc *JsonEncoder) AddFloat32(k string, v float32)
- func (enc *JsonEncoder) AddFloat64(key string, val float64)
- func (enc *JsonEncoder) AddInt(k string, v int)
- func (enc *JsonEncoder) AddInt16(k string, v int16)
- func (enc *JsonEncoder) AddInt32(k string, v int32)
- func (enc *JsonEncoder) AddInt64(key string, val int64)
- func (enc *JsonEncoder) AddInt8(k string, v int8)
- func (enc *JsonEncoder) AddObject(key string, obj zapcore.ObjectMarshaler) error
- func (enc *JsonEncoder) AddReflected(key string, obj interface{}) error
- func (enc *JsonEncoder) AddString(key, val string)
- func (enc *JsonEncoder) AddTime(key string, val time.Time)
- func (enc *JsonEncoder) AddUint(k string, v uint)
- func (enc *JsonEncoder) AddUint16(k string, v uint16)
- func (enc *JsonEncoder) AddUint32(k string, v uint32)
- func (enc *JsonEncoder) AddUint64(key string, val uint64)
- func (enc *JsonEncoder) AddUint8(k string, v uint8)
- func (enc *JsonEncoder) AddUintptr(k string, v uintptr)
- func (enc *JsonEncoder) AppendArray(arr zapcore.ArrayMarshaler) error
- func (enc *JsonEncoder) AppendBool(val bool)
- func (enc *JsonEncoder) AppendByteString(val []byte)
- func (enc *JsonEncoder) AppendComplex128(val complex128)
- func (enc *JsonEncoder) AppendComplex64(v complex64)
- func (enc *JsonEncoder) AppendDuration(val time.Duration)
- func (enc *JsonEncoder) AppendFloat32(v float32)
- func (enc *JsonEncoder) AppendFloat64(v float64)
- func (enc *JsonEncoder) AppendInt(v int)
- func (enc *JsonEncoder) AppendInt16(v int16)
- func (enc *JsonEncoder) AppendInt32(v int32)
- func (enc *JsonEncoder) AppendInt64(val int64)
- func (enc *JsonEncoder) AppendInt8(v int8)
- func (enc *JsonEncoder) AppendObject(obj zapcore.ObjectMarshaler) error
- func (enc *JsonEncoder) AppendReflected(val interface{}) error
- func (enc *JsonEncoder) AppendString(val string)
- func (enc *JsonEncoder) AppendTime(val time.Time)
- func (enc *JsonEncoder) AppendUint(v uint)
- func (enc *JsonEncoder) AppendUint16(v uint16)
- func (enc *JsonEncoder) AppendUint32(v uint32)
- func (enc *JsonEncoder) AppendUint64(val uint64)
- func (enc *JsonEncoder) AppendUint8(v uint8)
- func (enc *JsonEncoder) AppendUintptr(v uintptr)
- func (enc *JsonEncoder) Clone() zapcore.Encoder
- func (enc *JsonEncoder) EncodeEntry(ent zapcore.Entry, fields []zapcore.Field) (*buffer.Buffer, error)
- func (enc *JsonEncoder) OpenNamespace(key string)
- type Logger
- func (l *Logger) Debug(msg string, fields ...field)
- func (l *Logger) Error(msg string, fields ...field)
- func (l *Logger) Fatal(msg string, fields ...field)
- func (l *Logger) Handler() http.Handler
- func (l *Logger) Info(msg string, fields ...field)
- func (l *Logger) Panic(msg string, fields ...field)
- func (l *Logger) Warn(msg string, fields ...field)
- type Option
- type PrefixFn
Constants ¶
View Source
const ( // DebugLevel 打印Debug级别日志 DebugLevel level = zap.DebugLevel // InfoLevel 打印Info级别日志 InfoLevel level = zap.InfoLevel // WarnLevel 打印Warn级别日志 WarnLevel level = zap.WarnLevel // ErrorLevel 打印Error级别日志和调用栈 ErrorLevel level = zap.ErrorLevel // PanicLevel 打印Panic级别日志和调用栈并panic退出 PanicLevel level = zap.PanicLevel // FatalLevel 打印Fatal级别日志和调用栈并调用os.Exit(1)退出 FatalLevel level = zap.FatalLevel )
Variables ¶
View Source
var LevelM = map[level]string{ DebugLevel: "DEBUG", InfoLevel: "NOTICE", WarnLevel: "WARN", ErrorLevel: "FATAL", PanicLevel: "FATAL", FatalLevel: "FATAL", }
Functions ¶
func Error ¶
func Error(msg string, fields ...field)
Error 使用defaultLogger实例打印Error级别日志。注:此级别下会打印调用栈,请根据需求使用
func Fatal ¶
func Fatal(msg string, fields ...field)
Fatal 使用defaultLogger实例打印Fatal级别日志。注:此级别下会打印调用栈,同时会调用os.Exit(1)退出,请根据需求使用
func NewJSONEncoder ¶
func NewJSONEncoder(cfg EncoderConfig) zapcore.Encoder
NewJSONEncoder creates a fast, low-allocation JSON encoder. The encoder appropriately escapes all field keys and values.
Note that the encoder doesn't deduplicate keys, so it's possible to produce a message like
{"foo":"bar","foo":"baz"}
This is permitted by the JSON specification, but not encouraged. Many libraries will ignore duplicate key-value pairs (typically keeping the last pair) when unmarshaling, but users should attempt to avoid adding duplicate keys.
Types ¶
type EncoderConfig ¶
type EncoderConfig struct { zapcore.EncoderConfig PrefixFns []PrefixFn }
type JsonEncoder ¶
type JsonEncoder struct { *zapcore.EncoderConfig Buf *buffer.Buffer // contains filtered or unexported fields }
func (*JsonEncoder) AddArray ¶
func (enc *JsonEncoder) AddArray(key string, arr zapcore.ArrayMarshaler) error
func (*JsonEncoder) AddBinary ¶
func (enc *JsonEncoder) AddBinary(key string, val []byte)
func (*JsonEncoder) AddBool ¶
func (enc *JsonEncoder) AddBool(key string, val bool)
func (*JsonEncoder) AddByteString ¶
func (enc *JsonEncoder) AddByteString(key string, val []byte)
func (*JsonEncoder) AddComplex128 ¶
func (enc *JsonEncoder) AddComplex128(key string, val complex128)
func (*JsonEncoder) AddComplex64 ¶
func (enc *JsonEncoder) AddComplex64(k string, v complex64)
func (*JsonEncoder) AddDuration ¶
func (enc *JsonEncoder) AddDuration(key string, val time.Duration)
func (*JsonEncoder) AddFloat32 ¶
func (enc *JsonEncoder) AddFloat32(k string, v float32)
func (*JsonEncoder) AddFloat64 ¶
func (enc *JsonEncoder) AddFloat64(key string, val float64)
func (*JsonEncoder) AddInt ¶
func (enc *JsonEncoder) AddInt(k string, v int)
func (*JsonEncoder) AddInt16 ¶
func (enc *JsonEncoder) AddInt16(k string, v int16)
func (*JsonEncoder) AddInt32 ¶
func (enc *JsonEncoder) AddInt32(k string, v int32)
func (*JsonEncoder) AddInt64 ¶
func (enc *JsonEncoder) AddInt64(key string, val int64)
func (*JsonEncoder) AddInt8 ¶
func (enc *JsonEncoder) AddInt8(k string, v int8)
func (*JsonEncoder) AddObject ¶
func (enc *JsonEncoder) AddObject(key string, obj zapcore.ObjectMarshaler) error
func (*JsonEncoder) AddReflected ¶
func (enc *JsonEncoder) AddReflected(key string, obj interface{}) error
func (*JsonEncoder) AddString ¶
func (enc *JsonEncoder) AddString(key, val string)
func (*JsonEncoder) AddUint ¶
func (enc *JsonEncoder) AddUint(k string, v uint)
func (*JsonEncoder) AddUint16 ¶
func (enc *JsonEncoder) AddUint16(k string, v uint16)
func (*JsonEncoder) AddUint32 ¶
func (enc *JsonEncoder) AddUint32(k string, v uint32)
func (*JsonEncoder) AddUint64 ¶
func (enc *JsonEncoder) AddUint64(key string, val uint64)
func (*JsonEncoder) AddUint8 ¶
func (enc *JsonEncoder) AddUint8(k string, v uint8)
func (*JsonEncoder) AddUintptr ¶
func (enc *JsonEncoder) AddUintptr(k string, v uintptr)
func (*JsonEncoder) AppendArray ¶
func (enc *JsonEncoder) AppendArray(arr zapcore.ArrayMarshaler) error
func (*JsonEncoder) AppendBool ¶
func (enc *JsonEncoder) AppendBool(val bool)
func (*JsonEncoder) AppendByteString ¶
func (enc *JsonEncoder) AppendByteString(val []byte)
func (*JsonEncoder) AppendComplex128 ¶
func (enc *JsonEncoder) AppendComplex128(val complex128)
func (*JsonEncoder) AppendComplex64 ¶
func (enc *JsonEncoder) AppendComplex64(v complex64)
func (*JsonEncoder) AppendDuration ¶
func (enc *JsonEncoder) AppendDuration(val time.Duration)
func (*JsonEncoder) AppendFloat32 ¶
func (enc *JsonEncoder) AppendFloat32(v float32)
func (*JsonEncoder) AppendFloat64 ¶
func (enc *JsonEncoder) AppendFloat64(v float64)
func (*JsonEncoder) AppendInt ¶
func (enc *JsonEncoder) AppendInt(v int)
func (*JsonEncoder) AppendInt16 ¶
func (enc *JsonEncoder) AppendInt16(v int16)
func (*JsonEncoder) AppendInt32 ¶
func (enc *JsonEncoder) AppendInt32(v int32)
func (*JsonEncoder) AppendInt64 ¶
func (enc *JsonEncoder) AppendInt64(val int64)
func (*JsonEncoder) AppendInt8 ¶
func (enc *JsonEncoder) AppendInt8(v int8)
func (*JsonEncoder) AppendObject ¶
func (enc *JsonEncoder) AppendObject(obj zapcore.ObjectMarshaler) error
func (*JsonEncoder) AppendReflected ¶
func (enc *JsonEncoder) AppendReflected(val interface{}) error
func (*JsonEncoder) AppendString ¶
func (enc *JsonEncoder) AppendString(val string)
func (*JsonEncoder) AppendTime ¶
func (enc *JsonEncoder) AppendTime(val time.Time)
func (*JsonEncoder) AppendUint ¶
func (enc *JsonEncoder) AppendUint(v uint)
func (*JsonEncoder) AppendUint16 ¶
func (enc *JsonEncoder) AppendUint16(v uint16)
func (*JsonEncoder) AppendUint32 ¶
func (enc *JsonEncoder) AppendUint32(v uint32)
func (*JsonEncoder) AppendUint64 ¶
func (enc *JsonEncoder) AppendUint64(val uint64)
func (*JsonEncoder) AppendUint8 ¶
func (enc *JsonEncoder) AppendUint8(v uint8)
func (*JsonEncoder) AppendUintptr ¶
func (enc *JsonEncoder) AppendUintptr(v uintptr)
func (*JsonEncoder) Clone ¶
func (enc *JsonEncoder) Clone() zapcore.Encoder
func (*JsonEncoder) EncodeEntry ¶
func (*JsonEncoder) OpenNamespace ¶
func (enc *JsonEncoder) OpenNamespace(key string)
type Logger ¶
Logger 对zap.Logger进行了封装
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
An Option configures a Logger.
type PrefixFn ¶
type PrefixFn func(encoder *JsonEncoder, ent zapcore.Entry)
Click to show internal directories.
Click to hide internal directories.