Documentation
¶
Overview ¶
Package logger 提供基于 zap 的全局日志功能
Index ¶
- func Close() error
- func Debug(format string, args ...interface{})
- func Error(format string, args ...interface{})
- func Fatal(format string, args ...interface{})
- func Info(format string, args ...interface{})
- func Init(cfg Config) error
- func Panic(format string, args ...interface{})
- func Print(args ...interface{})
- func Printf(format string, args ...interface{})
- func Println(args ...interface{})
- func SetLevel(level string)
- func Sync() *zap.Logger
- func Warn(format string, args ...interface{})
- type Config
- type Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Level 日志级别: debug, info, warn, error
Level string `json:"level" yaml:"level"`
// Format 日志格式: text, json
Format string `json:"format" yaml:"format"`
// Output 输出目标: stdout, stderr, 或文件路径
Output string `json:"output" yaml:"output"`
// Prefix 日志前缀
Prefix string `json:"prefix" yaml:"prefix"`
// MaxSize 日志文件最大大小(MB),超过此大小会切割
MaxSize int `json:"max_size" yaml:"max_size"`
// MaxBackups 保留的旧日志文件最大数量
MaxBackups int `json:"max_backups" yaml:"max_backups"`
// MaxAge 保留旧日志文件的最大天数
MaxAge int `json:"max_age" yaml:"max_age"`
// Compress 是否压缩旧日志文件
Compress bool `json:"compress" yaml:"compress"`
}
Config 日志配置
type Logger ¶
type Logger struct {
*zap.SugaredLogger
// contains filtered or unexported fields
}
Logger 日志记录器
Click to show internal directories.
Click to hide internal directories.