优化日志分割代码

This commit is contained in:
liwei1dao 2022-08-08 16:10:42 +08:00
parent e167cce59e
commit fa554438c9

View File

@ -92,7 +92,7 @@ func (l *LogFileOut) openExistingOrNew(writeLen int) error {
}
//校验是否需要切割日志
if info.Size()+int64(writeLen) >= l.max() || time.Since(l.ctime) > l.CupTime {
if info.Size()+int64(writeLen) >= l.max() || (!l.ctime.IsZero() && time.Since(l.ctime) > l.CupTime) {
return l.rotate()
}