fix: avoid losing logs before closing (#3573)

This commit is contained in:
xt-inking
2023-09-17 19:38:53 +08:00
committed by GitHub
parent 0dcede6457
commit 5e435b6a76
2 changed files with 30 additions and 1 deletions

View File

@@ -381,7 +381,15 @@ func (l *RotateLogger) startWorker() {
case event := <-l.channel:
l.write(event)
case <-l.done:
return
// avoid losing logs before closing.
for {
select {
case event := <-l.channel:
l.write(event)
default:
return
}
}
}
}
}()