Logger: pre-create log files before lumberjack does

Clunky workaround for https://github.com/natefinch/lumberjack/issues/164
This commit is contained in:
Frank Denis 2023-02-25 23:42:38 +01:00
parent 03c6f92a5f
commit 47e6a56b16
1 changed files with 5 additions and 0 deletions

View File

@ -22,6 +22,11 @@ func Logger(logMaxSize int, logMaxAge int, logMaxBackups int, fileName string) i
}
return fp
}
if fp, err := os.OpenFile(fileName, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0o644); err == nil {
fp.Close()
} else {
dlog.Errorf("Unable to create [%v]: [%v]", fileName, err)
}
logger := &lumberjack.Logger{
LocalTime: true,
MaxSize: logMaxSize,