From ae16bd8b675b60bfaa58737e721d1cdb105552ed Mon Sep 17 00:00:00 2001 From: Godfrain Jacques Date: Mon, 5 Feb 2024 09:11:27 -0800 Subject: [PATCH] fix(settings): It's not possible to switch the log level (#13309) * chore: bump status-go Closes #13139 * fix(settings): It's not possible to switch the log level Previously it was not possible to change the state of the Debug toggle. This is because the code forced the setting the default value, ignoring the database setup, hence always setting the DEBUG as LogLevel. Closes #13139 --- .../profile_section/advanced/io_interface.nim | 3 +++ .../main/profile_section/advanced/module.nim | 3 +++ .../main/profile_section/advanced/view.nim | 5 +++++ src/app_service/service/accounts/service.nim | 3 ++- .../service/node_configuration/service.nim | 10 ++++++++-- .../AppLayouts/Profile/stores/AdvancedStore.qml | 1 + ui/app/AppLayouts/Profile/views/AdvancedView.qml | 16 ++++++++++++++++ .../shared/status/StatusSettingsLineButton.qml | 2 +- vendor/status-go | 2 +- 9 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/app/modules/main/profile_section/advanced/io_interface.nim b/src/app/modules/main/profile_section/advanced/io_interface.nim index 47e9210c74..937400b872 100644 --- a/src/app/modules/main/profile_section/advanced/io_interface.nim +++ b/src/app/modules/main/profile_section/advanced/io_interface.nim @@ -63,6 +63,9 @@ method toggleAutoMessage*(self: AccessInterface) {.base.} = method isDebugEnabled*(self: AccessInterface): bool {.base.} = raise newException(ValueError, "No implementation available") +method isRuntimeLogLevelSet*(self: AccessInterface): bool {.base.} = + raise newException(ValueError, "No implementation available") + method toggleDebug*(self: AccessInterface) {.base.} = raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/profile_section/advanced/module.nim b/src/app/modules/main/profile_section/advanced/module.nim index dbe5acf201..0628ceb8e1 100644 --- a/src/app/modules/main/profile_section/advanced/module.nim +++ b/src/app/modules/main/profile_section/advanced/module.nim @@ -105,6 +105,9 @@ method toggleDebug*(self: Module) = method onDebugToggled*(self: Module) = self.view.isDebugEnabledChanged() +method isRuntimeLogLevelSet*(self: Module): bool = + return constants.runtimeLogLevelSet() + method toggleWalletSection*(self: Module) = self.controller.toggleWalletSection() diff --git a/src/app/modules/main/profile_section/advanced/view.nim b/src/app/modules/main/profile_section/advanced/view.nim index b22e1f2d20..15c64cb2e3 100644 --- a/src/app/modules/main/profile_section/advanced/view.nim +++ b/src/app/modules/main/profile_section/advanced/view.nim @@ -88,6 +88,11 @@ QtObject: proc toggleDebug*(self: View) {.slot.} = self.delegate.toggleDebug() + proc getIsRuntimeLogLevelSet*(self: View): bool {.slot.} = + return self.delegate.isRuntimeLogLevelSet() + QtProperty[bool] isRuntimeLogLevelSet: + read = getIsRuntimeLogLevelSet + proc toggleWalletSection*(self: View) {.slot.} = self.delegate.toggleWalletSection() diff --git a/src/app_service/service/accounts/service.nim b/src/app_service/service/accounts/service.nim index d698c13a6d..7719a364c6 100644 --- a/src/app_service/service/accounts/service.nim +++ b/src/app_service/service/accounts/service.nim @@ -405,7 +405,8 @@ QtObject: "TorrentDir": DEFAULT_TORRENT_CONFIG_TORRENTDIR } - result["LogLevel"] = newJString(toStatusGoSupportedLogLevel(main_constants.LOG_LEVEL)) + if main_constants.runtimeLogLevelSet(): + result["RuntimeLogLevel"] = newJString(toStatusGoSupportedLogLevel(main_constants.LOG_LEVEL)) if STATUS_PORT != 0: result["ListenAddr"] = newJString("0.0.0.0:" & $main_constants.STATUS_PORT) diff --git a/src/app_service/service/node_configuration/service.nim b/src/app_service/service/node_configuration/service.nim index cf3f092a98..4d0f5065b9 100644 --- a/src/app_service/service/node_configuration/service.nim +++ b/src/app_service/service/node_configuration/service.nim @@ -5,6 +5,7 @@ import ../settings/service as settings_service import ../../../app/core/eventemitter import ../../../app/core/fleets/fleet_configuration import ../../../backend/node_config as status_node_config +import ../../../constants as main_constants export node_config @@ -14,7 +15,9 @@ logScope: const WAKU_VERSION_1* = 1 const WAKU_VERSION_2* = 2 -const SIGNAL_NODE_LOG_LEVEL_UPDATE* = "nodeLogLevelUpdated" +const + SIGNAL_NODE_LOG_LEVEL_UPDATE* = "nodeLogLevelUpdated" + DEBUG_LOG_LEVELS = @["DEBUG", "TRACE"] type NodeLogLevelUpdatedArgs* = ref object of Args @@ -194,7 +197,10 @@ proc getLogLevel(self: Service): string = return self.configuration.LogLevel proc isDebugEnabled*(self: Service): bool = - return self.getLogLevel() == $LogLevel.DEBUG + var logLevel = self.getLogLevel() + if main_constants.runtimeLogLevelSet(): + logLevel = main_constants.LOG_LEVEL + return logLevel in DEBUG_LOG_LEVELS proc setLogLevel*(self: Service, logLevel: LogLevel): bool = var newConfiguration = self.configuration diff --git a/ui/app/AppLayouts/Profile/stores/AdvancedStore.qml b/ui/app/AppLayouts/Profile/stores/AdvancedStore.qml index 55d24e6d6d..b6b850470c 100644 --- a/ui/app/AppLayouts/Profile/stores/AdvancedStore.qml +++ b/ui/app/AppLayouts/Profile/stores/AdvancedStore.qml @@ -16,6 +16,7 @@ QtObject { property bool isDebugEnabled: advancedModule? advancedModule.isDebugEnabled : false readonly property bool isWakuV2ShardedCommunitiesEnabled: localAppSettings.wakuV2ShardedCommunitiesEnabled ?? false property int logMaxBackups: advancedModule ? advancedModule.logMaxBackups : 1 + property bool isRuntimeLogLevelSet: advancedModule ? advancedModule.isRuntimeLogLevelSet: false property var customNetworksModel: advancedModule? advancedModule.customNetworksModel : [] diff --git a/ui/app/AppLayouts/Profile/views/AdvancedView.qml b/ui/app/AppLayouts/Profile/views/AdvancedView.qml index 54da602394..4781c11b58 100644 --- a/ui/app/AppLayouts/Profile/views/AdvancedView.qml +++ b/ui/app/AppLayouts/Profile/views/AdvancedView.qml @@ -354,10 +354,26 @@ SettingsContentBase { anchors.rightMargin: 0 text: qsTr("Debug") isSwitch: true + isEnabled: !root.advancedStore.isRuntimeLogLevelSet switchChecked: root.advancedStore.isDebugEnabled + onClicked: { Global.openPopup(enableDebugComponent) } + + MouseArea { + id: overlayMouseArea + anchors.fill: parent + enabled: true + hoverEnabled: true + propagateComposedEvents: true + } + + StatusToolTip { + text: qsTr("The value is overridden with runtime options") + visible: overlayMouseArea.containsMouse && root.advancedStore.isRuntimeLogLevelSet + delay: 1000 + } } // TODO: replace with StatusQ component diff --git a/ui/imports/shared/status/StatusSettingsLineButton.qml b/ui/imports/shared/status/StatusSettingsLineButton.qml index b3ba646c07..3d7da84edd 100644 --- a/ui/imports/shared/status/StatusSettingsLineButton.qml +++ b/ui/imports/shared/status/StatusSettingsLineButton.qml @@ -54,7 +54,7 @@ Rectangle { anchors.verticalCenter: parent.verticalCenter text: root.text font.pixelSize: 15 - color: !root.isEnabled ? Style.current.secondaryText : Style.current.textColor + color: Style.current.textColor } StyledText { diff --git a/vendor/status-go b/vendor/status-go index 9c131edfaa..4584de34b0 160000 --- a/vendor/status-go +++ b/vendor/status-go @@ -1 +1 @@ -Subproject commit 9c131edfaa47ab38fe25048a7116dc4c54336336 +Subproject commit 4584de34b096f93e6f1be760cd1105f956c91962