From f79ab8a6a54942a279529926360ad9b921c293af Mon Sep 17 00:00:00 2001 From: Jia Sui Date: Fri, 31 Jan 2020 20:35:50 +0800 Subject: [PATCH] file: delete outdated files after rotate (#15) --- file.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/file.go b/file.go index 6ad8bf6..25c05f3 100644 --- a/file.go +++ b/file.go @@ -199,6 +199,10 @@ func (l *fileLogger) write(m Messager) (int, error) { l.openDay = now.Day() l.currentSize = 0 l.currentLines = 0 + + if err := l.deleteOutdatedFiles(); err != nil { + return bytesWrote, fmt.Errorf("delete outdated file: %v", err) + } } } return bytesWrote, nil