|
@@ -51,14 +51,15 @@ func getzapLevel(level string) zapcore.Level {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-func newLogWriter(logpath string, maxsize int, compress bool) io.Writer {
|
|
|
|
|
|
+func newLogWriter(logpath string, maxsize, maxbacks int, compress bool) io.Writer {
|
|
if logpath == "" || logpath == "-" {
|
|
if logpath == "" || logpath == "-" {
|
|
return os.Stdout
|
|
return os.Stdout
|
|
}
|
|
}
|
|
return &lumberjack.Logger{
|
|
return &lumberjack.Logger{
|
|
- Filename: logpath,
|
|
|
|
- MaxSize: maxsize,
|
|
|
|
- Compress: compress,
|
|
|
|
|
|
+ Filename: logpath,
|
|
|
|
+ MaxSize: maxsize,
|
|
|
|
+ MaxBackups: maxbacks,
|
|
|
|
+ Compress: compress,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -80,7 +81,7 @@ func newZapEncoder() zapcore.EncoderConfig {
|
|
return encoderConfig
|
|
return encoderConfig
|
|
}
|
|
}
|
|
func newLoggerCore(log *logConfig) zapcore.Core {
|
|
func newLoggerCore(log *logConfig) zapcore.Core {
|
|
- hook := newLogWriter(log.LogPath, log.MaxSize, log.Compress)
|
|
|
|
|
|
+ hook := newLogWriter(log.LogPath, log.MaxSize, log.MaxBackups, log.Compress)
|
|
|
|
|
|
encoderConfig := newZapEncoder()
|
|
encoderConfig := newZapEncoder()
|
|
|
|
|