Fix `TRACE` log level support (#12935)

This commit is contained in:
Igor Sirotin 2023-12-06 11:25:57 +00:00 committed by GitHub
parent 0b26070833
commit 6c6967faf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 5 deletions

View File

@ -1,4 +1,4 @@
import NimQml, sequtils, sugar, chronicles, os, uuids
import NimQml, sequtils, sugar, chronicles, uuids
import ../../app_service/service/general/service as general_service
import ../../app_service/service/keychain/service as keychain_service
@ -133,7 +133,7 @@ proc connect(self: AppController) =
discard
# Handle runtime log level settings changes
if not existsEnv("LOG_LEVEL"):
if not main_constants.runtimeLogLevelSet():
self.statusFoundation.events.on(node_configuration_service.SIGNAL_NODE_LOG_LEVEL_UPDATE) do(a: Args):
let args = NodeLogLevelUpdatedArgs(a)
if args.logLevel == chronicles.LogLevel.DEBUG:
@ -439,7 +439,7 @@ proc load(self: AppController) =
self.walletAccountService.init()
# Apply runtime log level settings
if not existsEnv("LOG_LEVEL"):
if not main_constants.runtimeLogLevelSet():
if self.nodeConfigurationService.isDebugEnabled():
setLogLevel(chronicles.LogLevel.DEBUG)

View File

@ -263,6 +263,11 @@ QtObject:
if(self.importedAccount.id == accountId):
return self.prepareSubaccountJsonObject(self.importedAccount, displayName)
proc toStatusGoSupportedLogLevel*(logLevel: string): string =
if logLevel == "TRACE":
return "DEBUG"
return logLevel
proc prepareAccountSettingsJsonObject(self: Service, account: GeneratedAccountDto,
installationId: string, displayName: string): JsonNode =
result = %* {
@ -343,7 +348,7 @@ QtObject:
result["ClusterConfig"]["DiscV5BootstrapNodes"] = %* (@[])
result["Rendezvous"] = newJBool(false)
result["LogLevel"] = newJString(main_constants.LOG_LEVEL)
result["LogLevel"] = newJString(toStatusGoSupportedLogLevel(main_constants.LOG_LEVEL))
if STATUS_PORT != 0:
result["ListenAddr"] = newJString("0.0.0.0:" & $main_constants.STATUS_PORT)
@ -407,7 +412,7 @@ QtObject:
"TorrentDir": DEFAULT_TORRENT_CONFIG_TORRENTDIR
}
result["LogLevel"] = newJString(main_constants.LOG_LEVEL)
result["LogLevel"] = newJString(toStatusGoSupportedLogLevel(main_constants.LOG_LEVEL))
if STATUS_PORT != 0:
result["ListenAddr"] = newJString("0.0.0.0:" & $main_constants.STATUS_PORT)

View File

@ -60,3 +60,12 @@ let
RARIBLE_TESTNET_API_KEY_RESOLVED* = desktopConfig.raribleTestnetApiKey
TENOR_API_KEY_RESOLVED* = desktopConfig.tenorApiKey
WALLET_CONNECT_PROJECT_ID* = BUILD_WALLET_CONNECT_PROJECT_ID
proc hasLogLevelOption*(): bool =
for p in cliParams:
if p.startswith("--log-level") or p.startsWith("--LOG_LEVEL"):
return true
return false
proc runtimeLogLevelSet*(): bool =
return existsEnv(RUN_TIME_PREFIX & "_LOG_LEVEL") or hasLogLevelOption()