优化结构

This commit is contained in:
Yvan
2026-08-28 11:51:37 +08:00
parent 5b04998731
commit 33ba777137
25 changed files with 163 additions and 125 deletions
+3
View File
@@ -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()
}