Documentation
¶
Index ¶
- Constants
- Variables
- func Debug(msg string, fields ...zap.Field)
- func Error(msg string, fields ...zap.Field)
- func GetLevel() zapcore.Level
- func GetLevelStr() string
- func Info(msg string, fields ...zap.Field)
- func Level2String(level zapcore.Level) string
- func ParseLevel(level string) zapcore.Level
- func SetDefaultLogger(logger *Logger)
- func SetLogLevel(level zapcore.Level)
- func SetLogLevelStr(levelStr string)
- func Warn(msg string, fields ...zap.Field)
- type BoolArray
- type ByteStringsArray
- type Complex64Array
- type Complex128Array
- type CounterLogger
- type DurationArray
- type Float32Array
- type Float64Array
- type Int8Array
- type Int16Array
- type Int32Array
- type Int64Array
- type IntArray
- type Key
- type LogFunc
- type Logger
- func (z *Logger) Debug(msg string, fields ...zap.Field)
- func (z *Logger) Error(msg string, fields ...zap.Field)
- func (z *Logger) Info(msg string, fields ...zap.Field)
- func (z *Logger) Level() zapcore.Level
- func (z *Logger) LevelStr() string
- func (z *Logger) SetLevel(level zapcore.Level)
- func (z *Logger) SetLevelStr(sLevel string)
- func (z *Logger) Sync() error
- func (z *Logger) Warn(msg string, fields ...zap.Field)
- type StringArray
- type TimeArray
- type TimeKey
- type TimeLogger
- func (x TimeLogger) Debug(tk TimeKey, msg string, args ...zap.Field)
- func (x TimeLogger) GetDuration() time.Duration
- func (x TimeLogger) Info(tk TimeKey, msg string, args ...zap.Field)
- func (x TimeLogger) SetDuration(dur time.Duration)
- func (x TimeLogger) Warn(tk TimeKey, msg string, args ...zap.Field)
- type Uint8Array
- type Uint16Array
- type Uint32Array
- type Uint64Array
- type UintArray
- type ZapConf
- type Zaps
Constants ¶
const ( //level string DebugLevelStr = "debug" InfoLevelStr = "info" WarnLevelStr = "warn" ErrorLevelStr = "error" //level define DebugLevel = zap.DebugLevel InfoLevel = zap.InfoLevel WarnLevel = zap.WarnLevel ErrorLevel = zap.ErrorLevel )
Variables ¶
var ( //ErrZapEmpty empty zap logger ErrZapEmpty = errors.New("zap.pointer.empty") )
Functions ¶
Types ¶
type BoolArray ¶ added in v1.0.2
type BoolArray []bool
func (BoolArray) MarshalLogArray ¶ added in v1.0.2
func (bs BoolArray) MarshalLogArray(arr zapcore.ArrayEncoder) error
type ByteStringsArray ¶ added in v1.0.2
type ByteStringsArray [][]byte
func (ByteStringsArray) MarshalLogArray ¶ added in v1.0.2
func (bss ByteStringsArray) MarshalLogArray(arr zapcore.ArrayEncoder) error
type Complex64Array ¶ added in v1.0.2
type Complex64Array []complex64
func (Complex64Array) MarshalLogArray ¶ added in v1.0.2
func (nums Complex64Array) MarshalLogArray(arr zapcore.ArrayEncoder) error
type Complex128Array ¶ added in v1.0.2
type Complex128Array []complex128
func (Complex128Array) MarshalLogArray ¶ added in v1.0.2
func (nums Complex128Array) MarshalLogArray(arr zapcore.ArrayEncoder) error
type CounterLogger ¶ added in v1.3.9
type CounterLogger struct {
// contains filtered or unexported fields
}
CounterLogger is a generic struct that maps keys of any type K to integer counters.
func NewCounterLogger ¶ added in v1.3.9
func NewCounterLogger(interval int64) CounterLogger
NewCounterLogger creates a new CounterLogger instance.
func (CounterLogger) Debug ¶ added in v1.3.9
func (x CounterLogger) Debug(k Key, msg string, args ...zap.Field)
Debug logs a debug message if the count for the given key exceeds the set interval.
func (CounterLogger) GetInterval ¶ added in v1.3.9
func (x CounterLogger) GetInterval() int64
GetInterval gets the interval for the CounterLogger.
func (CounterLogger) Info ¶ added in v1.3.9
func (x CounterLogger) Info(k Key, msg string, args ...zap.Field)
Info logs an info message if the count for the given key exceeds the set interval.
func (CounterLogger) SetInterval ¶ added in v1.3.9
func (x CounterLogger) SetInterval(interval int64)
SetInterval sets the interval for the CounterLogger.
type DurationArray ¶ added in v1.0.2
func (DurationArray) MarshalLogArray ¶ added in v1.0.2
func (ds DurationArray) MarshalLogArray(arr zapcore.ArrayEncoder) error
type Float32Array ¶ added in v1.0.2
type Float32Array []float32
func (Float32Array) MarshalLogArray ¶ added in v1.0.2
func (nums Float32Array) MarshalLogArray(arr zapcore.ArrayEncoder) error
type Float64Array ¶ added in v1.0.2
type Float64Array []float64
func (Float64Array) MarshalLogArray ¶ added in v1.0.2
func (nums Float64Array) MarshalLogArray(arr zapcore.ArrayEncoder) error
type Int8Array ¶ added in v1.0.2
type Int8Array []int8
func (Int8Array) MarshalLogArray ¶ added in v1.0.2
func (nums Int8Array) MarshalLogArray(arr zapcore.ArrayEncoder) error
type Int16Array ¶ added in v1.0.2
type Int16Array []int16
func (Int16Array) MarshalLogArray ¶ added in v1.0.2
func (nums Int16Array) MarshalLogArray(arr zapcore.ArrayEncoder) error
type Int32Array ¶ added in v1.0.2
type Int32Array []int32
func (Int32Array) MarshalLogArray ¶ added in v1.0.2
func (nums Int32Array) MarshalLogArray(arr zapcore.ArrayEncoder) error
type Int64Array ¶ added in v1.0.2
type Int64Array []int64
func (Int64Array) MarshalLogArray ¶ added in v1.0.2
func (nums Int64Array) MarshalLogArray(arr zapcore.ArrayEncoder) error
type IntArray ¶ added in v1.0.2
type IntArray []int
func (IntArray) MarshalLogArray ¶ added in v1.0.2
func (nums IntArray) MarshalLogArray(arr zapcore.ArrayEncoder) error
type Key ¶ added in v1.3.9
type Key interface {
// Key extracts the key of type K
Key() any
}
Key : an interface for key abstraction
type Logger ¶
Logger 封装可以动态设置log level的logger
func NewSimpleLogger ¶
NewSimpleLogger new zap logger without file log
func (*Logger) SetLevelStr ¶
SetLevelStr set level string
type StringArray ¶ added in v1.0.2
type StringArray []string
func (StringArray) MarshalLogArray ¶ added in v1.0.2
func (ss StringArray) MarshalLogArray(arr zapcore.ArrayEncoder) error
type TimeArray ¶ added in v1.0.2
func (TimeArray) MarshalLogArray ¶ added in v1.0.2
func (ts TimeArray) MarshalLogArray(arr zapcore.ArrayEncoder) error
type TimeKey ¶ added in v1.3.9
type TimeKey interface {
// Key extracts the key of type K
Key() any
// ExtractTime extracts the time.Time value
ExtractTime() time.Time
}
TimeKey : an interface for time abstraction
type TimeLogger ¶ added in v1.3.9
type TimeLogger struct {
// contains filtered or unexported fields
}
TimeLogger is a generic struct that maps keys of any type K to time.Time values.
func NewTimeLogger ¶ added in v1.3.9
func NewTimeLogger(dur time.Duration) TimeLogger
NewTimeLogger creates a new TimeLogger instance.
func (TimeLogger) Debug ¶ added in v1.3.9
func (x TimeLogger) Debug(tk TimeKey, msg string, args ...zap.Field)
Debug logs a debug message if the time since the last log for the given key exceeds the set duration.
func (TimeLogger) GetDuration ¶ added in v1.3.9
func (x TimeLogger) GetDuration() time.Duration
GetDuration gets the duration for the TimeLogger.
func (TimeLogger) Info ¶ added in v1.3.9
func (x TimeLogger) Info(tk TimeKey, msg string, args ...zap.Field)
Info logs an info message if the time since the last log for the given key exceeds the set duration.
func (TimeLogger) SetDuration ¶ added in v1.3.9
func (x TimeLogger) SetDuration(dur time.Duration)
SetDuration sets the duration for the TimeLogger.
type Uint8Array ¶ added in v1.0.2
type Uint8Array []uint8
func (Uint8Array) MarshalLogArray ¶ added in v1.0.2
func (nums Uint8Array) MarshalLogArray(arr zapcore.ArrayEncoder) error
type Uint16Array ¶ added in v1.0.2
type Uint16Array []uint16
func (Uint16Array) MarshalLogArray ¶ added in v1.0.2
func (nums Uint16Array) MarshalLogArray(arr zapcore.ArrayEncoder) error
type Uint32Array ¶ added in v1.0.2
type Uint32Array []uint32
func (Uint32Array) MarshalLogArray ¶ added in v1.0.2
func (nums Uint32Array) MarshalLogArray(arr zapcore.ArrayEncoder) error
type Uint64Array ¶ added in v1.0.2
type Uint64Array []uint64
func (Uint64Array) MarshalLogArray ¶ added in v1.0.2
func (nums Uint64Array) MarshalLogArray(arr zapcore.ArrayEncoder) error
type UintArray ¶ added in v1.0.2
type UintArray []uint
func (UintArray) MarshalLogArray ¶ added in v1.0.2
func (nums UintArray) MarshalLogArray(arr zapcore.ArrayEncoder) error
type ZapConf ¶
type ZapConf struct {
//文件名
FileName string `json:"fileName" toml:"fileName"`
//文件最大长度 (M bytes)
MaxSize int `json:"maxSize" toml:"maxSize"`
//文件最久天数
MaxAge int `json:"maxAge" toml:"maxAge"`
//最大备份文件数量
MaxBackups int `json:"maxBackups" toml:"maxBackups"`
//是否在备份文件格式中使用utc time,否则为local time
UTCTime bool `json:"utcTime" toml:"utcTime"`
//是否压缩旧的文件
Compress bool `json:"compress" toml:"compress"`
//Disable log caller
DisableCaller bool `json:"disableCaller" toml:"disableCaller"`
//log level
LogLevel string `json:"logLevel" toml:"logLevel"`
}
ZapConf zap configuration