mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-16 18:43:10 -06:00
Fix race condition
This commit is contained in:
parent
f4d6704d95
commit
333f0596dc
|
|
@ -24,6 +24,7 @@ import (
|
|||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/matrix-org/util"
|
||||
|
||||
|
|
@ -37,6 +38,7 @@ import (
|
|||
// this unfortunately results in us adding the same hook multiple times.
|
||||
// This map ensures we only ever add one level hook.
|
||||
var stdLevelLogAdded = make(map[logrus.Level]bool)
|
||||
var levelLogAddedMu = &sync.Mutex{}
|
||||
|
||||
type utcFormatter struct {
|
||||
logrus.Formatter
|
||||
|
|
|
|||
|
|
@ -85,6 +85,8 @@ func checkSyslogHookParams(params map[string]interface{}) {
|
|||
}
|
||||
|
||||
func setupStdLogHook(level logrus.Level) {
|
||||
levelLogAddedMu.Lock()
|
||||
defer levelLogAddedMu.Unlock()
|
||||
if stdLevelLogAdded[level] {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue