Proper log rotation, filename compatibility with windows
This commit is contained in:
@@ -54,11 +54,13 @@ func NewLogger(logPath string) *Logger {
|
||||
consoleEncoderCore := zapcore.NewCore(consoleEncoder, zapcore.AddSync(os.Stdout), zapLevel)
|
||||
|
||||
// Set up file logging with overwrite mode
|
||||
logFile := zapcore.AddSync(&lumberjack.Logger{
|
||||
lj := lumberjack.Logger{
|
||||
Filename: logPath,
|
||||
MaxSize: 10, // megabytes
|
||||
MaxBackups: 20,
|
||||
})
|
||||
}
|
||||
lj.Rotate()
|
||||
logFile := zapcore.AddSync(&lj)
|
||||
fmt.Println("Logging to", logPath)
|
||||
|
||||
fileCfg := zapcore.EncoderConfig{
|
||||
|
||||
Reference in New Issue
Block a user