From 4d05feb68c6b303718decc729e6939954a6b4245 Mon Sep 17 00:00:00 2001 From: RainyBow Date: Thu, 11 Jul 2024 09:27:00 +0800 Subject: [PATCH] =?UTF-8?q?fix-bug:=20rotate=20=E4=B8=8D=E5=8E=8B=E7=BC=A9?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lumberjack.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lumberjack.go b/lumberjack.go index 5920915..a25e567 100644 --- a/lumberjack.go +++ b/lumberjack.go @@ -165,6 +165,10 @@ func (l *Logger) Write(p []byte) (n int, err error) { func (l *Logger) Close() error { l.mu.Lock() defer l.mu.Unlock() + if l.millCh != nil { + close(l.millCh) + l.millCh = nil + } return l.close() } @@ -175,10 +179,6 @@ func (l *Logger) close() error { } err := l.file.Close() l.file = nil - if l.millCh != nil { - close(l.millCh) - l.millCh = nil - } return err }