Documentation
¶
Index ¶
- Constants
- func DPanic(args ...interface{})
- func DPanicf(template string, args ...interface{})
- func Debug(args ...interface{})
- func Debugf(template string, args ...interface{})
- func Error(args ...interface{})
- func Errorf(template string, args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(template string, args ...interface{})
- func Info(args ...interface{})
- func Infof(template string, args ...interface{})
- func NewContext(ctx context.Context, fields ...zapcore.Field) context.Context
- func NewTextEncoder(cfg zapcore.EncoderConfig) zapcore.Encoder
- func Operator() *zap.Logger
- func Panic(args ...interface{})
- func Panicf(template string, args ...interface{})
- func PrintLogo()
- func StdPrintf(format string, v ...interface{})
- func StdPrintln(v ...interface{})
- func TraceIdField(ctx context.Context) zap.Field
- func Warn(args ...interface{})
- func Warnf(template string, args ...interface{})
- type Config
- type Logger
- func (l *Logger) Apply(cfg *conf.Configuration, path string)
- func (l Logger) AsGlobal()
- func (l *Logger) DPanic(msg string, fields ...zap.Field)
- func (l *Logger) Debug(msg string, fields ...zap.Field)
- func (l *Logger) Error(msg string, fields ...zap.Field)
- func (l *Logger) Fatal(msg string, fields ...zap.Field)
- func (l *Logger) Info(msg string, fields ...zap.Field)
- func (l Logger) Operator() *zap.Logger
- func (l *Logger) Panic(msg string, fields ...zap.Field)
- func (l *Logger) Sync() error
- func (l *Logger) Warn(msg string, fields ...zap.Field)
- func (l *Logger) With(fields ...zapcore.Field) *Logger
- type TextEncoder
- func (enc *TextEncoder) AddArray(key string, marshaler zapcore.ArrayMarshaler) (err error)
- func (enc *TextEncoder) AddBinary(key string, value []byte)
- func (enc *TextEncoder) AddBool(key string, value bool)
- func (enc *TextEncoder) AddByteString(key string, value []byte)
- func (enc *TextEncoder) AddComplex128(key string, value complex128)
- func (enc *TextEncoder) AddComplex64(key string, value complex64)
- func (enc *TextEncoder) AddDuration(key string, value time.Duration)
- func (enc *TextEncoder) AddFloat32(key string, value float32)
- func (enc *TextEncoder) AddFloat64(key string, value float64)
- func (enc *TextEncoder) AddInt(key string, value int)
- func (enc *TextEncoder) AddInt16(key string, value int16)
- func (enc *TextEncoder) AddInt32(key string, value int32)
- func (enc *TextEncoder) AddInt64(key string, value int64)
- func (enc *TextEncoder) AddInt8(key string, value int8)
- func (enc *TextEncoder) AddObject(key string, marshaler zapcore.ObjectMarshaler) (err error)
- func (enc *TextEncoder) AddReflected(key string, value interface{}) (err error)
- func (enc *TextEncoder) AddString(key, value string)
- func (enc *TextEncoder) AddTime(key string, value time.Time)
- func (enc *TextEncoder) AddUint(key string, value uint)
- func (enc *TextEncoder) AddUint16(key string, value uint16)
- func (enc *TextEncoder) AddUint32(key string, value uint32)
- func (enc *TextEncoder) AddUint64(key string, value uint64)
- func (enc *TextEncoder) AddUint8(key string, value uint8)
- func (enc *TextEncoder) AddUintptr(key string, value uintptr)
- func (enc *TextEncoder) AppendArray(arr zapcore.ArrayMarshaler) (err error)
- func (enc *TextEncoder) AppendBool(value bool)
- func (enc *TextEncoder) AppendByteString(value []byte)
- func (enc *TextEncoder) AppendComplex128(value complex128)
- func (enc *TextEncoder) AppendComplex64(value complex64)
- func (enc *TextEncoder) AppendDuration(value time.Duration)
- func (enc *TextEncoder) AppendFloat32(value float32)
- func (enc *TextEncoder) AppendFloat64(value float64)
- func (enc *TextEncoder) AppendInt(value int)
- func (enc *TextEncoder) AppendInt16(value int16)
- func (enc *TextEncoder) AppendInt32(value int32)
- func (enc *TextEncoder) AppendInt64(value int64)
- func (enc *TextEncoder) AppendInt8(value int8)
- func (enc *TextEncoder) AppendObject(obj zapcore.ObjectMarshaler) (err error)
- func (enc *TextEncoder) AppendReflected(value interface{}) (err error)
- func (enc *TextEncoder) AppendString(value string)
- func (enc *TextEncoder) AppendTime(value time.Time)
- func (enc *TextEncoder) AppendUint(value uint)
- func (enc *TextEncoder) AppendUint16(value uint16)
- func (enc *TextEncoder) AppendUint32(value uint32)
- func (enc *TextEncoder) AppendUint64(value uint64)
- func (enc *TextEncoder) AppendUint8(value uint8)
- func (enc *TextEncoder) AppendUintptr(value uintptr)
- func (enc *TextEncoder) Clone() zapcore.Encoder
- func (enc *TextEncoder) EncodeEntry(zapcore.Entry, []zapcore.Field) (buf *buffer.Buffer, err error)
- func (enc *TextEncoder) OpenNamespace(key string)
Constants ¶
const ( // ContextHeaderName opentracing log key is trace.traceid ContextHeaderName = iota TraceIdKey = "traceid" SpanIdKey = "spanid" )
Variables ¶
This section is empty.
Functions ¶
func Debugf ¶
func Debugf(template string, args ...interface{})
Debugf uses fmt.Sprintf to log a templated message.
func NewContext ¶
NewContext creates a new context the given contextual fields
func NewTextEncoder ¶
func NewTextEncoder(cfg zapcore.EncoderConfig) zapcore.Encoder
func TraceIdField ¶
TraceIdField get trace id of zap field type
Types ¶
type Config ¶
type Config struct { Tee []zap.Config `json:"tee" yaml:"tee"` Sole *zap.Config `json:"sole" yaml:"sole"` Rotate *lumberjack.Logger `json:"rotate" yaml:"rotate"` // contains filtered or unexported fields }
Config is logger schema Tee use as zap advance,such as zapcore.NewTee() Sole use as one zap logger core
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger integrate the Uber Zap library to use in woocoo
if you prefer to golang builtin log style,use log.Info or log.Infof, if zap style,you should use log.Operator().Info()
func WithContext ¶
WithContext returns a logger from the given context
func (*Logger) Apply ¶
func (l *Logger) Apply(cfg *conf.Configuration, path string)
Apply implement Configurable interface which can initial from a file used in JSON,YAML Logger init trough Apply method will be set as Global.
type TextEncoder ¶
type TextEncoder struct { *zapcore.EncoderConfig // contains filtered or unexported fields }
func (*TextEncoder) AddArray ¶
func (enc *TextEncoder) AddArray(key string, marshaler zapcore.ArrayMarshaler) (err error)
Logging-specific marshalers.
func (*TextEncoder) AddBinary ¶
func (enc *TextEncoder) AddBinary(key string, value []byte)
Built-in types. for arbitrary bytes
func (*TextEncoder) AddBool ¶
func (enc *TextEncoder) AddBool(key string, value bool)
func (*TextEncoder) AddByteString ¶
func (enc *TextEncoder) AddByteString(key string, value []byte)
func (*TextEncoder) AddComplex128 ¶
func (enc *TextEncoder) AddComplex128(key string, value complex128)
func (*TextEncoder) AddComplex64 ¶
func (enc *TextEncoder) AddComplex64(key string, value complex64)
func (*TextEncoder) AddDuration ¶
func (enc *TextEncoder) AddDuration(key string, value time.Duration)
func (*TextEncoder) AddFloat32 ¶
func (enc *TextEncoder) AddFloat32(key string, value float32)
func (*TextEncoder) AddFloat64 ¶
func (enc *TextEncoder) AddFloat64(key string, value float64)
func (*TextEncoder) AddInt ¶
func (enc *TextEncoder) AddInt(key string, value int)
func (*TextEncoder) AddInt16 ¶
func (enc *TextEncoder) AddInt16(key string, value int16)
func (*TextEncoder) AddInt32 ¶
func (enc *TextEncoder) AddInt32(key string, value int32)
func (*TextEncoder) AddInt64 ¶
func (enc *TextEncoder) AddInt64(key string, value int64)
func (*TextEncoder) AddInt8 ¶
func (enc *TextEncoder) AddInt8(key string, value int8)
func (*TextEncoder) AddObject ¶
func (enc *TextEncoder) AddObject(key string, marshaler zapcore.ObjectMarshaler) (err error)
func (*TextEncoder) AddReflected ¶
func (enc *TextEncoder) AddReflected(key string, value interface{}) (err error)
AddReflected uses reflection to serialize arbitrary objects, so it can be slow and allocation-heavy.
func (*TextEncoder) AddString ¶
func (enc *TextEncoder) AddString(key, value string)
func (*TextEncoder) AddUint ¶
func (enc *TextEncoder) AddUint(key string, value uint)
func (*TextEncoder) AddUint16 ¶
func (enc *TextEncoder) AddUint16(key string, value uint16)
func (*TextEncoder) AddUint32 ¶
func (enc *TextEncoder) AddUint32(key string, value uint32)
func (*TextEncoder) AddUint64 ¶
func (enc *TextEncoder) AddUint64(key string, value uint64)
func (*TextEncoder) AddUint8 ¶
func (enc *TextEncoder) AddUint8(key string, value uint8)
func (*TextEncoder) AddUintptr ¶
func (enc *TextEncoder) AddUintptr(key string, value uintptr)
func (*TextEncoder) AppendArray ¶
func (enc *TextEncoder) AppendArray(arr zapcore.ArrayMarshaler) (err error)
Logging-specific marshalers.{}
func (*TextEncoder) AppendBool ¶
func (enc *TextEncoder) AppendBool(value bool)
func (*TextEncoder) AppendByteString ¶
func (enc *TextEncoder) AppendByteString(value []byte)
for UTF-8 encoded bytes
func (*TextEncoder) AppendComplex128 ¶
func (enc *TextEncoder) AppendComplex128(value complex128)
func (*TextEncoder) AppendComplex64 ¶
func (enc *TextEncoder) AppendComplex64(value complex64)
func (*TextEncoder) AppendDuration ¶
func (enc *TextEncoder) AppendDuration(value time.Duration)
Time-related types.
func (*TextEncoder) AppendFloat32 ¶
func (enc *TextEncoder) AppendFloat32(value float32)
func (*TextEncoder) AppendFloat64 ¶
func (enc *TextEncoder) AppendFloat64(value float64)
func (*TextEncoder) AppendInt ¶
func (enc *TextEncoder) AppendInt(value int)
func (*TextEncoder) AppendInt16 ¶
func (enc *TextEncoder) AppendInt16(value int16)
func (*TextEncoder) AppendInt32 ¶
func (enc *TextEncoder) AppendInt32(value int32)
func (*TextEncoder) AppendInt64 ¶
func (enc *TextEncoder) AppendInt64(value int64)
func (*TextEncoder) AppendInt8 ¶
func (enc *TextEncoder) AppendInt8(value int8)
func (*TextEncoder) AppendObject ¶
func (enc *TextEncoder) AppendObject(obj zapcore.ObjectMarshaler) (err error)
func (*TextEncoder) AppendReflected ¶
func (enc *TextEncoder) AppendReflected(value interface{}) (err error)
AppendReflected uses reflection to serialize arbitrary objects, so it's{} slow and allocation-heavy.{}
func (*TextEncoder) AppendString ¶
func (enc *TextEncoder) AppendString(value string)
func (*TextEncoder) AppendTime ¶
func (enc *TextEncoder) AppendTime(value time.Time)
func (*TextEncoder) AppendUint ¶
func (enc *TextEncoder) AppendUint(value uint)
func (*TextEncoder) AppendUint16 ¶
func (enc *TextEncoder) AppendUint16(value uint16)
func (*TextEncoder) AppendUint32 ¶
func (enc *TextEncoder) AppendUint32(value uint32)
func (*TextEncoder) AppendUint64 ¶
func (enc *TextEncoder) AppendUint64(value uint64)
func (*TextEncoder) AppendUint8 ¶
func (enc *TextEncoder) AppendUint8(value uint8)
func (*TextEncoder) AppendUintptr ¶
func (enc *TextEncoder) AppendUintptr(value uintptr)
func (*TextEncoder) Clone ¶
func (enc *TextEncoder) Clone() zapcore.Encoder
Clone copies the encoder, ensuring that adding fields to the copy doesn't affect the original.
func (*TextEncoder) EncodeEntry ¶
EncodeEntry encodes an entry and fields, along with any accumulated context, into a byte buffer and returns ienc. Any fields that are empty, including fields on the `Entry` type, should be omitted.
func (*TextEncoder) OpenNamespace ¶
func (enc *TextEncoder) OpenNamespace(key string)
OpenNamespace opens an isolated namespace where all subsequent fields will be added. Applications can use namespaces to prevent key collisions when injecting loggers into sub-components or third-party libraries.