Improve logging control flow

This commit is contained in:
Daniel 2022-11-04 16:12:42 +01:00
parent 70b58138b9
commit f6f644fd8e
2 changed files with 5 additions and 2 deletions

View file

@ -93,7 +93,10 @@ func log(level Severity, msg string, tracer *ContextTracer) {
// wake up writer if necessary
if logsWaitingFlag.SetToIf(false, true) {
logsWaiting <- struct{}{}
select {
case logsWaiting <- struct{}{}:
default:
}
}
}

View file

@ -109,7 +109,7 @@ var (
pkgLevels = make(map[string]Severity)
pkgLevelsLock sync.Mutex
logsWaiting = make(chan struct{}, 4)
logsWaiting = make(chan struct{}, 1)
logsWaitingFlag = abool.NewBool(false)
shutdownFlag = abool.NewBool(false)