Documentation ¶
Index ¶
Constants ¶
View Source
const ( ZapFormatJson = "json" ZapFormatText = "text" ZapEncodeLevelLower = "lower" ZapEncodeLevelLowerColor = "lowerColor" ZapEncodeLevelCap = "cap" ZapEncodeLevelCapColor = "capColor" )
View Source
const LoggerKey = "zapLogger"
Variables ¶
View Source
var Default = NewLog(&Zap{Director: "logs"})
View Source
var FileRotatelogs = new(fileRotatelogs)
Functions ¶
Types ¶
type Logger ¶
type Logger struct {
*zap.SugaredLogger
}
func (*Logger) NewContext ¶
NewContext 给指定的context添加字段
type Zap ¶
type Zap struct { Level string `mapstructure:"level" yaml:"level"` // 级别 Prefix string `mapstructure:"prefix" yaml:"prefix"` // 日志前缀 Format string `mapstructure:"format" yaml:"format"` // 输出,json或text Director string `mapstructure:"director" yaml:"director"` // 日志文件夹 EncodeLevel string `mapstructure:"encode-level" yaml:"encode-level"` // 编码级 StacktraceKey string `mapstructure:"stacktrace-key" yaml:"stacktrace-key"` // 栈名 MaxAge int `mapstructure:"max-age" yaml:"max-age"` // 日志留存时间 ShowLine bool `mapstructure:"show-line" yaml:"show-line"` // 显示行 LogInConsole bool `mapstructure:"log-in-console" yaml:"log-in-console"` // 输出控制台 }
func (*Zap) TransportLevel ¶
TransportLevel 根据字符串转化为 zapcore.Level
func (*Zap) ZapEncodeLevel ¶
func (z *Zap) ZapEncodeLevel() zapcore.LevelEncoder
ZapEncodeLevel 根据 EncodeLevel 返回 zapcore.LevelEncoder
Click to show internal directories.
Click to hide internal directories.