mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[MM-27952] Fix some logging related races (#15404)
* Fix some logging races * Move initLogging after config store initialization
This commit is contained in:
@@ -184,7 +184,6 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
hashSeed: maphash.MakeSeed(),
|
||||
}
|
||||
|
||||
mlog.Info("Server is initializing...")
|
||||
for _, option := range options {
|
||||
if err := option(s); err != nil {
|
||||
return nil, errors.Wrap(err, "failed to apply option")
|
||||
@@ -204,6 +203,9 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
mlog.Error(err.Error())
|
||||
}
|
||||
|
||||
// This is called after initLogging() to avoid a race condition.
|
||||
mlog.Info("Server is initializing...")
|
||||
|
||||
// It is important to initialize the hub only after the global logger is set
|
||||
// to avoid race conditions while logging from inside the hub.
|
||||
fakeApp := New(ServerConnector(s))
|
||||
|
||||
@@ -35,7 +35,7 @@ func NewTestingLogger(tb testing.TB, writer io.Writer) *Logger {
|
||||
logrLogger: newLogr(),
|
||||
}
|
||||
|
||||
logWriterCore := zapcore.NewCore(makeEncoder(true), logWriterSync, testingLogger.consoleLevel)
|
||||
logWriterCore := zapcore.NewCore(makeEncoder(true), zapcore.Lock(logWriterSync), testingLogger.consoleLevel)
|
||||
|
||||
testingLogger.zap = zap.New(logWriterCore,
|
||||
zap.AddCaller(),
|
||||
|
||||
Reference in New Issue
Block a user