mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-18 11:33:10 -06:00
Move log creation mutexes up a level to prevent races in unit tests
This commit is contained in:
parent
7900bfeb52
commit
eae2db401b
|
|
@ -101,6 +101,8 @@ func SetupPprof() {
|
||||||
|
|
||||||
// SetupStdLogging configures the logging format to standard output. Typically, it is called when the config is not yet loaded.
|
// SetupStdLogging configures the logging format to standard output. Typically, it is called when the config is not yet loaded.
|
||||||
func SetupStdLogging() {
|
func SetupStdLogging() {
|
||||||
|
levelLogAddedMu.Lock()
|
||||||
|
defer levelLogAddedMu.Unlock()
|
||||||
logrus.SetReportCaller(true)
|
logrus.SetReportCaller(true)
|
||||||
logrus.SetFormatter(&utcFormatter{
|
logrus.SetFormatter(&utcFormatter{
|
||||||
&logrus.TextFormatter{
|
&logrus.TextFormatter{
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,8 @@ import (
|
||||||
// If something fails here it means that the logging was improperly configured,
|
// If something fails here it means that the logging was improperly configured,
|
||||||
// so we just exit with the error
|
// so we just exit with the error
|
||||||
func SetupHookLogging(hooks []config.LogrusHook, componentName string) {
|
func SetupHookLogging(hooks []config.LogrusHook, componentName string) {
|
||||||
|
levelLogAddedMu.Lock()
|
||||||
|
defer levelLogAddedMu.Unlock()
|
||||||
for _, hook := range hooks {
|
for _, hook := range hooks {
|
||||||
// Check we received a proper logging level
|
// Check we received a proper logging level
|
||||||
level, err := logrus.ParseLevel(hook.Level)
|
level, err := logrus.ParseLevel(hook.Level)
|
||||||
|
|
@ -85,8 +87,6 @@ func checkSyslogHookParams(params map[string]interface{}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupStdLogHook(level logrus.Level) {
|
func setupStdLogHook(level logrus.Level) {
|
||||||
levelLogAddedMu.Lock()
|
|
||||||
defer levelLogAddedMu.Unlock()
|
|
||||||
if stdLevelLogAdded[level] {
|
if stdLevelLogAdded[level] {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue