Documentation ¶
Index ¶
- Constants
- Variables
- func AddHook(hook Hook)
- func Close()
- func Debug(msg string, fields ...zap.Field)
- func Debugf(args ...interface{})
- func DefaultConsoleConfig(title string) *zapcore.EncoderConfig
- func Error(msg string, fields ...zap.Field) error
- func Errorf(args ...interface{})
- func Fatal(msg string, fields ...zap.Field)
- func Fatalf(args ...interface{})
- func Info(msg string, fields ...zap.Field)
- func Infof(args ...interface{})
- func Init(dev bool, conf *LogConfig, hooks ...Hook)
- func InitDefault(dev bool, console bool, title string, hooks ...Hook)
- func IsConsole() bool
- func NewEncoderConfig(title string, console bool) *zapcore.EncoderConfig
- func Panic(msg string, fields ...zap.Field)
- func Panicf(args ...interface{})
- func PrettyStruct(s interface{}) string
- func RemoveHook(hook Hook)
- func SetDefaultLogger(logger *ComposeLogger)
- func Sync() error
- func TimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
- func Warn(msg string, fields ...zap.Field)
- func Warnf(args ...interface{})
- type ComposeEncoder
- func (this ComposeEncoder) AddArray(k string, v zapcore.ArrayMarshaler) error
- func (this ComposeEncoder) AddBinary(k string, v []byte)
- func (this ComposeEncoder) AddBool(k string, v bool)
- func (this ComposeEncoder) AddByteString(k string, v []byte)
- func (this ComposeEncoder) AddComplex128(k string, v complex128)
- func (this ComposeEncoder) AddComplex64(k string, v complex64)
- func (this ComposeEncoder) AddDuration(k string, v time.Duration)
- func (this ComposeEncoder) AddFloat32(k string, v float32)
- func (this ComposeEncoder) AddFloat64(k string, v float64)
- func (this ComposeEncoder) AddInt(k string, v int)
- func (this ComposeEncoder) AddInt16(k string, v int16)
- func (this ComposeEncoder) AddInt32(k string, v int32)
- func (this ComposeEncoder) AddInt64(k string, v int64)
- func (this ComposeEncoder) AddInt8(k string, v int8)
- func (this ComposeEncoder) AddObject(k string, v zapcore.ObjectMarshaler) error
- func (this ComposeEncoder) AddReflected(k string, v interface{}) error
- func (this ComposeEncoder) AddString(k string, v string)
- func (this ComposeEncoder) AddTime(k string, v time.Time)
- func (this ComposeEncoder) AddUint(k string, v uint)
- func (this ComposeEncoder) AddUint16(k string, v uint16)
- func (this ComposeEncoder) AddUint32(k string, v uint32)
- func (this ComposeEncoder) AddUint64(k string, v uint64)
- func (this ComposeEncoder) AddUint8(k string, v uint8)
- func (this ComposeEncoder) AddUintptr(k string, v uintptr)
- func (this ComposeEncoder) Clone() *ComposeEncoder
- func (this ComposeEncoder) EncodeEntry(entry zapcore.Entry, fields []zapcore.Field) (*buffer.Buffer, error)
- func (this ComposeEncoder) OpenNamespace(k string)
- type ComposeLogger
- func (this *ComposeLogger) AddHook(hook Hook)
- func (this *ComposeLogger) Clear()
- func (this *ComposeLogger) Clone() *ComposeLogger
- func (this *ComposeLogger) Debug(msg string, fields ...zap.Field)
- func (this *ComposeLogger) Debugf(args ...interface{})
- func (this *ComposeLogger) Error(msg string, fields ...zap.Field) error
- func (this *ComposeLogger) Errorf(args ...interface{})
- func (this *ComposeLogger) Fatal(msg string, fields ...zap.Field)
- func (this *ComposeLogger) Fatalf(args ...interface{})
- func (this *ComposeLogger) Info(msg string, fields ...zap.Field)
- func (this *ComposeLogger) Infof(args ...interface{})
- func (this *ComposeLogger) Panic(msg string, fields ...zap.Field)
- func (this *ComposeLogger) Panicf(args ...interface{})
- func (this *ComposeLogger) RemoveConsoleWriter(writer io.Writer)
- func (this *ComposeLogger) RemoveHook(hook Hook)
- func (this *ComposeLogger) SetConsoleWriter(writer io.Writer)
- func (this *ComposeLogger) SetJsonWriter(writer io.Writer)
- func (this *ComposeLogger) SetObjectWriter(writer ObjectWriter)
- func (this *ComposeLogger) Sync() error
- func (this *ComposeLogger) Warn(msg string, fields ...zap.Field)
- func (this *ComposeLogger) Warnf(args ...interface{})
- func (this *ComposeLogger) WithField(key string, value interface{}) *ComposeLogger
- func (this *ComposeLogger) WithFields(fields Fields) *ComposeLogger
- func (this *ComposeLogger) Write(p []byte) (int, error)
- func (this *ComposeLogger) WriteConsole(ent zapcore.Entry, p []byte) error
- func (this *ComposeLogger) WriteJson(ent zapcore.Entry, p []byte) error
- func (this *ComposeLogger) WriteObject(ent zapcore.Entry, data map[string]interface{}) error
- func (this *ComposeLogger) WriteString(s string)
- type Field
- type Fields
- type FileRotateConf
- type FileRotateHook
- type FileRotateOpt
- type Hook
- type ILogger
- type LogConfig
- type LoggerWithFields
- type MongoConf
- type ObjectWriter
- type StdLogger
- type TestLogger
- type ZapCompose
- func (this *ZapCompose) Check(ent zapcore.Entry, che *zapcore.CheckedEntry) *zapcore.CheckedEntry
- func (this *ZapCompose) Enabled(level zapcore.Level) bool
- func (this *ZapCompose) Sync() error
- func (this *ZapCompose) With(fields []zapcore.Field) zapcore.Core
- func (this *ZapCompose) Write(ent zapcore.Entry, fields []zapcore.Field) error
- type ZapFields
Constants ¶
const ( ConsoleEncoder string = "console" JsonEncoder string = "json" ObjEncoder string = "obj" )
Variables ¶
var DefaultJsonConfig = zapcore.EncoderConfig{ LevelKey: "level", NameKey: "logger", CallerKey: "caller", MessageKey: "msg", StacktraceKey: "stacktrace", LineEnding: zapcore.DefaultLineEnding, EncodeLevel: zapcore.CapitalLevelEncoder, EncodeTime: nil, EncodeDuration: zapcore.SecondsDurationEncoder, EncodeCaller: zapcore.ShortCallerEncoder, }
var DefaultJsonConfigWithTime = zapcore.EncoderConfig{ TimeKey: "time", LevelKey: "level", NameKey: "logger", CallerKey: "caller", MessageKey: "msg", StacktraceKey: "stacktrace", LineEnding: zapcore.DefaultLineEnding, EncodeLevel: zapcore.CapitalLevelEncoder, EncodeTime: TimeEncoder, EncodeDuration: zapcore.SecondsDurationEncoder, EncodeCaller: zapcore.ShortCallerEncoder, }
Functions ¶
func DefaultConsoleConfig ¶ added in v0.2.33
func DefaultConsoleConfig(title string) *zapcore.EncoderConfig
func NewEncoderConfig ¶ added in v0.2.33
func NewEncoderConfig(title string, console bool) *zapcore.EncoderConfig
func PrettyStruct ¶
func PrettyStruct(s interface{}) string
func RemoveHook ¶
func RemoveHook(hook Hook)
func SetDefaultLogger ¶
func SetDefaultLogger(logger *ComposeLogger)
func TimeEncoder ¶
func TimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
Types ¶
type ComposeEncoder ¶
type ComposeEncoder struct { zapcore.ObjectEncoder Fields map[string]interface{} // contains filtered or unexported fields }
func NewComposeEncoder ¶
func NewComposeEncoder(cfg *zapcore.EncoderConfig, enableJson, enableObj bool) *ComposeEncoder
func (ComposeEncoder) AddArray ¶
func (this ComposeEncoder) AddArray(k string, v zapcore.ArrayMarshaler) error
func (ComposeEncoder) AddBinary ¶
func (this ComposeEncoder) AddBinary(k string, v []byte)
AddBinary implements composeEnc.
func (ComposeEncoder) AddBool ¶
func (this ComposeEncoder) AddBool(k string, v bool)
AddBool implements composeEnc.
func (ComposeEncoder) AddByteString ¶
func (this ComposeEncoder) AddByteString(k string, v []byte)
AddByteString implements composeEnc.
func (ComposeEncoder) AddComplex128 ¶
func (this ComposeEncoder) AddComplex128(k string, v complex128)
AddComplex128 implements composeEnc.
func (ComposeEncoder) AddComplex64 ¶
func (this ComposeEncoder) AddComplex64(k string, v complex64)
AddComplex64 implements composeEnc.
func (ComposeEncoder) AddDuration ¶
func (this ComposeEncoder) AddDuration(k string, v time.Duration)
AddDuration implements composeEnc.
func (ComposeEncoder) AddFloat32 ¶
func (this ComposeEncoder) AddFloat32(k string, v float32)
AddFloat32 implements composeEnc.
func (ComposeEncoder) AddFloat64 ¶
func (this ComposeEncoder) AddFloat64(k string, v float64)
AddFloat64 implements composeEnc.
func (ComposeEncoder) AddInt ¶
func (this ComposeEncoder) AddInt(k string, v int)
AddInt implements composeEnc.
func (ComposeEncoder) AddInt16 ¶
func (this ComposeEncoder) AddInt16(k string, v int16)
AddInt16 implements composeEnc.
func (ComposeEncoder) AddInt32 ¶
func (this ComposeEncoder) AddInt32(k string, v int32)
AddInt32 implements composeEnc.
func (ComposeEncoder) AddInt64 ¶
func (this ComposeEncoder) AddInt64(k string, v int64)
AddInt64 implements composeEnc.
func (ComposeEncoder) AddInt8 ¶
func (this ComposeEncoder) AddInt8(k string, v int8)
AddInt8 implements composeEnc.
func (ComposeEncoder) AddObject ¶
func (this ComposeEncoder) AddObject(k string, v zapcore.ObjectMarshaler) error
AddObject implements composeEnc.
func (ComposeEncoder) AddReflected ¶
func (this ComposeEncoder) AddReflected(k string, v interface{}) error
AddReflected implements composeEnc.
func (ComposeEncoder) AddString ¶
func (this ComposeEncoder) AddString(k string, v string)
AddString implements composeEnc.
func (ComposeEncoder) AddTime ¶
func (this ComposeEncoder) AddTime(k string, v time.Time)
AddTime implements composeEnc.
func (ComposeEncoder) AddUint ¶
func (this ComposeEncoder) AddUint(k string, v uint)
AddUint implements composeEnc.
func (ComposeEncoder) AddUint16 ¶
func (this ComposeEncoder) AddUint16(k string, v uint16)
AddUint16 implements composeEnc.
func (ComposeEncoder) AddUint32 ¶
func (this ComposeEncoder) AddUint32(k string, v uint32)
AddUint32 implements composeEnc.
func (ComposeEncoder) AddUint64 ¶
func (this ComposeEncoder) AddUint64(k string, v uint64)
AddUint64 implements composeEnc.
func (ComposeEncoder) AddUint8 ¶
func (this ComposeEncoder) AddUint8(k string, v uint8)
AddUint8 implements composeEnc.
func (ComposeEncoder) AddUintptr ¶
func (this ComposeEncoder) AddUintptr(k string, v uintptr)
AddUintptr implements composeEnc.
func (ComposeEncoder) Clone ¶
func (this ComposeEncoder) Clone() *ComposeEncoder
func (ComposeEncoder) EncodeEntry ¶
func (ComposeEncoder) OpenNamespace ¶
func (this ComposeEncoder) OpenNamespace(k string)
OpenNamespace implements composeEnc.
type ComposeLogger ¶
type ComposeLogger struct {
// contains filtered or unexported fields
}
func DefaultLogger ¶
func DefaultLogger() *ComposeLogger
func NewComposeLogger ¶
func NewComposeLogger(dev bool, conf *LogConfig, skip int, hooks ...Hook) *ComposeLogger
func WithField ¶
func WithField(key string, value interface{}) *ComposeLogger
func WithFields ¶
func WithFields(fields Fields) *ComposeLogger
func (*ComposeLogger) AddHook ¶
func (this *ComposeLogger) AddHook(hook Hook)
func (*ComposeLogger) Clear ¶ added in v0.1.24
func (this *ComposeLogger) Clear()
func (*ComposeLogger) Clone ¶
func (this *ComposeLogger) Clone() *ComposeLogger
func (*ComposeLogger) Debugf ¶
func (this *ComposeLogger) Debugf(args ...interface{})
func (*ComposeLogger) Error ¶
func (this *ComposeLogger) Error(msg string, fields ...zap.Field) error
func (*ComposeLogger) Errorf ¶
func (this *ComposeLogger) Errorf(args ...interface{})
func (*ComposeLogger) Fatalf ¶
func (this *ComposeLogger) Fatalf(args ...interface{})
func (*ComposeLogger) Infof ¶
func (this *ComposeLogger) Infof(args ...interface{})
func (*ComposeLogger) Panicf ¶
func (this *ComposeLogger) Panicf(args ...interface{})
func (*ComposeLogger) RemoveConsoleWriter ¶
func (this *ComposeLogger) RemoveConsoleWriter(writer io.Writer)
func (*ComposeLogger) RemoveHook ¶
func (this *ComposeLogger) RemoveHook(hook Hook)
func (*ComposeLogger) SetConsoleWriter ¶
func (this *ComposeLogger) SetConsoleWriter(writer io.Writer)
func (*ComposeLogger) SetJsonWriter ¶
func (this *ComposeLogger) SetJsonWriter(writer io.Writer)
func (*ComposeLogger) SetObjectWriter ¶
func (this *ComposeLogger) SetObjectWriter(writer ObjectWriter)
func (*ComposeLogger) Sync ¶
func (this *ComposeLogger) Sync() error
func (*ComposeLogger) Warnf ¶
func (this *ComposeLogger) Warnf(args ...interface{})
func (*ComposeLogger) WithField ¶
func (this *ComposeLogger) WithField(key string, value interface{}) *ComposeLogger
func (*ComposeLogger) WithFields ¶
func (this *ComposeLogger) WithFields(fields Fields) *ComposeLogger
func (*ComposeLogger) WriteConsole ¶
func (this *ComposeLogger) WriteConsole(ent zapcore.Entry, p []byte) error
func (*ComposeLogger) WriteJson ¶
func (this *ComposeLogger) WriteJson(ent zapcore.Entry, p []byte) error
func (*ComposeLogger) WriteObject ¶
func (this *ComposeLogger) WriteObject(ent zapcore.Entry, data map[string]interface{}) error
func (*ComposeLogger) WriteString ¶
func (this *ComposeLogger) WriteString(s string)
type FileRotateConf ¶
type FileRotateConf struct { }
type FileRotateHook ¶
type FileRotateHook struct {
// contains filtered or unexported fields
}
func NewFileRotationHook ¶
func NewFileRotationHook(opt *FileRotateOpt) *FileRotateHook
func (*FileRotateHook) WriteConsole ¶
func (this *FileRotateHook) WriteConsole(ent zapcore.Entry, p []byte) error
func (*FileRotateHook) WriteJson ¶
func (this *FileRotateHook) WriteJson(ent zapcore.Entry, p []byte) error
func (*FileRotateHook) WriteObject ¶
func (this *FileRotateHook) WriteObject(ent zapcore.Entry, m map[string]interface{}) error
type FileRotateOpt ¶
type Hook ¶
type Hook interface { WriteConsole(zapcore.Entry, []byte) error WriteJson(zapcore.Entry, []byte) error WriteObject(zapcore.Entry, map[string]interface{}) error }
func NewConsoleWriter ¶
func NewJsonWriter ¶
func NewObjectWriter ¶
func NewObjectWriter(writer ObjectWriter) Hook
type ILogger ¶
type ILogger interface { Clear() Infof(args ...interface{}) Debugf(args ...interface{}) Warnf(args ...interface{}) Errorf(args ...interface{}) Panicf(args ...interface{}) Fatalf(args ...interface{}) Info(msg string, fields ...zap.Field) Debug(msg string, fields ...zap.Field) Warn(msg string, fields ...zap.Field) Error(msg string, fields ...zap.Field) error Panic(msg string, fields ...zap.Field) Fatal(msg string, fields ...zap.Field) WriteString(s string) Write(p []byte) (int, error) }
type LogConfig ¶
type LogConfig struct { Title string EncodeCfg *zapcore.EncoderConfig Console bool JsonConsole bool Json bool Object bool FileRotateConf FileRotateConf }
func ConsoleConfig ¶
func CustomConfig ¶ added in v0.2.33
func CustomConfig(json, console, jsonConsole, object bool, config *zapcore.EncoderConfig) *LogConfig
func DefaultConfig ¶
type LoggerWithFields ¶
type LoggerWithFields struct {
// contains filtered or unexported fields
}
type ObjectWriter ¶
type TestLogger ¶
type TestLogger struct {
// contains filtered or unexported fields
}
func NewAstilecTronLogger ¶
func NewAstilecTronLogger(enabled bool) *TestLogger
func (*TestLogger) Fatal ¶
func (this *TestLogger) Fatal(fields ...interface{})
func (*TestLogger) Fatalf ¶
func (this *TestLogger) Fatalf(msg string, fields ...interface{})
func (*TestLogger) Print ¶
func (this *TestLogger) Print(fields ...interface{})
func (*TestLogger) Printf ¶
func (this *TestLogger) Printf(msg string, fields ...interface{})
type ZapCompose ¶
type ZapCompose struct {
// contains filtered or unexported fields
}
func NewZapCompose ¶
func NewZapCompose(cfg *LogConfig, hook ...Hook) *ZapCompose
func (*ZapCompose) Check ¶
func (this *ZapCompose) Check(ent zapcore.Entry, che *zapcore.CheckedEntry) *zapcore.CheckedEntry
func (*ZapCompose) Sync ¶
func (this *ZapCompose) Sync() error