From 60d00e8fe83df9dd1ac1f4bda3a7f2a52c62ad5e Mon Sep 17 00:00:00 2001 From: Volodymyr Kozieiev Date: Wed, 7 Aug 2024 12:52:06 +0100 Subject: [PATCH] fix_: remove the restriction to call InitLogging only once --- mobile/status.go | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/mobile/status.go b/mobile/status.go index 2beffe27b..b5629167d 100644 --- a/mobile/status.go +++ b/mobile/status.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "os" - "sync" "unsafe" validator "gopkg.in/go-playground/validator.v9" @@ -1401,10 +1400,8 @@ func DeserializeAndCompressKey(DesktopKey string) string { return CompressPublicKey(sanitisedKey) } -var initLoggingOnce sync.Once - -// InitLogging The InitLogging function should be called only once during the application's lifetime, -// specifically when the application starts. This ensures that we can capture logs before the user login. +// InitLogging The InitLogging function should be called when the application starts. +// This ensures that we can capture logs before the user login. Subsequent calls will update the logger settings. // Before this, we can only capture logs after user login since we will only configure the logging after the login process. func InitLogging(logSettingsJSON string) string { var logSettings logutils.LogSettings @@ -1412,12 +1409,10 @@ func InitLogging(logSettingsJSON string) string { if err = json.Unmarshal([]byte(logSettingsJSON), &logSettings); err != nil { return makeJSONResponse(err) } - - initLoggingOnce.Do(func() { - if err = logutils.OverrideRootLogWithConfig(logSettings, false); err == nil { - log.Info("logging initialised", "logSettings", logSettingsJSON) - } - }) + + if err = logutils.OverrideRootLogWithConfig(logSettings, false); err == nil { + log.Info("logging initialised", "logSettings", logSettingsJSON) + } return makeJSONResponse(err) }