Documentation
¶
Index ¶
- Variables
- func GenRandomID(length int) (string, error)
- func InitLogger(conf *LoggerConfig) (err error)
- type Field
- func Any(key string, value interface{}) Field
- func Bool(key string, val bool) Field
- func ByteString(key string, val []byte) Field
- func Duration(key string, val time.Duration) Field
- func Float32(key string, val float32) Field
- func Float64(key string, val float64) Field
- func Int(key string, val int) Field
- func Int32(key string, val int32) Field
- func Int64(key string, val int64) Field
- func String(key string, val string) Field
- func Time(key string, val time.Time) Field
- func Uintptr(key string, val uintptr) Field
- type Logger
- func (l *Logger) DPanic(msg string, fields ...Field)
- func (l *Logger) Debug(msg string, fields ...Field)
- func (l *Logger) Error(err error, fields ...Field)
- func (l *Logger) Fatal(msg string, fields ...Field)
- func (l *Logger) Info(msg string, fields ...Field)
- func (l *Logger) Panic(msg error, fields ...Field)
- func (l *Logger) Sync() error
- func (l *Logger) Warn(msg string, fields ...Field)
- func (l *Logger) With(fields ...Field) *Logger
- type LoggerConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultLoggerConfig = &LoggerConfig{ Level: "info", TextMode: true, Console: true, } )
Functions ¶
Types ¶
type Field ¶
func ByteString ¶
type Logger ¶
func AddOperationID ¶
type LoggerConfig ¶
type LoggerConfig struct {
Level string `yaml:"level" json:"level"` // debug, info, warn, error, dpanic, panic, fatal
TextMode bool `yaml:"text_mode" json:"text_mode"` // 是否以文本格式输出日志,默认为json格式输出
Console bool `yaml:"console" json:"console"` // 是否输出到终端,在未指定日志文件名,默认输出到终端
Path string `yaml:"path" json:"path"` // 日志文件存放路径
MaxSize int `yaml:"max_size" json:"max_size"` // megabytes
MaxBackups int `yaml:"max_backups" json:"max_backups"` // 保留旧文件的最大个数
MaxAge int `yaml:"max_age" json:"max_age"` // 天数
Compress bool `yaml:"compress" json:"compress"` // 是否压缩/归档旧文件
}
Click to show internal directories.
Click to hide internal directories.