Documentation
¶
Index ¶
- func Debug(template string, args ...interface{})
- func Debugw(msg string, keysAndValues ...interface{})
- func Error(template string, args ...interface{})
- func Errorw(msg string, keysAndValues ...interface{})
- func Fatal(template string, args ...interface{})
- func Fatalw(msg string, keysAndValues ...interface{})
- func GetSugar() *zap.SugaredLogger
- func Info(template string, args ...interface{})
- func Infow(msg string, keysAndValues ...interface{})
- func New(cfg Config)
- func Warn(template string, args ...interface{})
- func Warnw(msg string, keysAndValues ...interface{})
- type Config
- type DailyLumberjack
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSugar ¶
func GetSugar() *zap.SugaredLogger
GetSugar 供外部获取原始的 SugaredLogger,主要为了实现特定功能如 WithContext
Types ¶
type Config ¶
type Config struct {
Level string // debug, info, warn, error
Stdout bool // 是否输出到控制台
Dir string // 基础日志目录
Filename string // 基础日志文件名
MaxSize int // 单个文件最大大小 (MB)
MaxBackups int // 最大旧文件保留个数
MaxAge int // 最大保留天数
Compress bool // 是否对旧日志压缩
}
Config 定义完整的日志配置
type DailyLumberjack ¶
type DailyLumberjack struct {
// contains filtered or unexported fields
}
DailyLumberjack 包装 lumberjack.Logger,实现按日期生成目录+文件尺寸切割双维度
func NewDailyLumberjack ¶
func NewDailyLumberjack(cfg Config) *DailyLumberjack
NewDailyLumberjack 创建一个新的 DailyLumberjack 实例
func (*DailyLumberjack) Close ¶
func (l *DailyLumberjack) Close() error
func (*DailyLumberjack) Sync ¶
func (l *DailyLumberjack) Sync() error
Click to show internal directories.
Click to hide internal directories.