优化结构
This commit is contained in:
@@ -50,6 +50,9 @@ func (w *DailyWriter) Write(value []byte) (int, error) {
|
||||
defer w.mu.Unlock()
|
||||
date := time.Now().Format("2006-01-02")
|
||||
if w.file == nil || w.date != date {
|
||||
// Retention is enforced again when a long-lived writer rolls to a new day.
|
||||
// Running this only on rotation avoids a directory scan for every write.
|
||||
w.removeExpired()
|
||||
if w.file != nil {
|
||||
_ = w.file.Close()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user