Documentation ¶
Index ¶
- Variables
- func CustomTimeFormat(t time.Time, format string) string
- func Debug(args ...interface{})
- func Debugf(format string, args ...interface{})
- func DefaultTimeFormat(t time.Time) []byte
- func Error(args ...interface{})
- func Errorf(format string, args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(format string, args ...interface{})
- func GetLogger() *zap.SugaredLogger
- func Info(args ...interface{})
- func Infof(format string, args ...interface{})
- func InitLogger(opc []OutputConfig)
- func NewTimeEncoder(format string) zapcore.TimeEncoder
- func Warn(args ...interface{})
- func Warnf(format string, args ...interface{})
- type FormatConfig
- type OutputConfig
- type Wrapper
- func (w *Wrapper) Debug(args ...interface{})
- func (w *Wrapper) Debugf(format string, args ...interface{})
- func (w *Wrapper) Error(args ...interface{})
- func (w *Wrapper) Errorf(format string, args ...interface{})
- func (w *Wrapper) Fatal(args ...interface{})
- func (w *Wrapper) Fatalf(format string, args ...interface{})
- func (w *Wrapper) Info(args ...interface{})
- func (w *Wrapper) Infof(format string, args ...interface{})
- func (w *Wrapper) Warn(args ...interface{})
- func (w *Wrapper) Warnf(format string, args ...interface{})
- type WriteConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var Levels = map[string]zapcore.Level{ "": zapcore.DebugLevel, "debug": zapcore.DebugLevel, "info": zapcore.InfoLevel, "warn": zapcore.WarnLevel, "error": zapcore.ErrorLevel, "fatal": zapcore.FatalLevel, }
Levels zap日志级别映射表
Functions ¶
func CustomTimeFormat ¶
CustomTimeFormat 自定义时间格式
func NewTimeEncoder ¶
func NewTimeEncoder(format string) zapcore.TimeEncoder
NewTimeEncoder 创建时间格式encoder
Types ¶
type FormatConfig ¶
type FormatConfig struct { // TimeFmt 日志输出时间格式,空默认为"2006-01-02 15:04:05.000" TimeFmt string `yaml:"time_fmt"` // TimeKey 日志输出时间key, 默认为"Timestamp" TimeKey string `yaml:"time_key"` // LevelKey 日志级别输出key, 默认为"Level" LevelKey string `yaml:"level_key"` // NameKey 日志名称key, 默认为"Name" NameKey string `yaml:"name_key"` // CallerKey 日志输出调用者key, 默认"Caller" CallerKey string `yaml:"caller_key"` // FunctionKey 日志输出调用者函数名, 默认"",表示不打印函数名 FunctionKey string `yaml:"function_key"` // MessageKey 日志输出消息体key,默认"Message" MessageKey string `yaml:"message_key"` // StacktraceKey 日志输出堆栈trace key, 默认"Stacktrace" StacktraceKey string `yaml:"stacktrace_key"` }
FormatConfig Formater配置
type OutputConfig ¶
type OutputConfig struct { // 日志输出端 (file,console) Writer string `yaml:"writer"` WriteConfig WriteConfig `yaml:"write_config"` // 日志输出格式 (console, json) Formatter string `yaml:"formatter"` FormatConfig FormatConfig `yaml:"format_config"` Level string `yaml:"level"` }
OutputConfig 日志配置结构体
type Wrapper ¶
type Wrapper struct {
// contains filtered or unexported fields
}
Wrapper 代理logger,使得With与Debug等日志调用栈层数一致
type WriteConfig ¶
type WriteConfig struct { // 文件日志路径(含文件名) LogPath string `yaml:"log_path"` // 日志最大大小 单位(MB) MaxSize int `yaml:"max_size"` // 日志最大保留时间,单位(天) MaxAge int `yaml:"max_age"` // 日志最大保留文件数 MaxBackups int `yaml:"max_backups"` // 是否启用压缩 Compress bool `yaml:"compress"` }
WriteConfig Writer配置
Click to show internal directories.
Click to hide internal directories.