feat: add toggle for switching status-go DEBUG log level
This commit is contained in:
parent
c9a0488e89
commit
44e91df428
|
@ -43,3 +43,9 @@ method toggleTelemetry*[T](self: Controller[T]) =
|
||||||
|
|
||||||
method isTelemetryEnabled*[T](self: Controller[T]): bool =
|
method isTelemetryEnabled*[T](self: Controller[T]): bool =
|
||||||
return self.settingsService.isTelemetryEnabled()
|
return self.settingsService.isTelemetryEnabled()
|
||||||
|
|
||||||
|
method toggleDebug*[T](self: Controller[T]) =
|
||||||
|
self.settingsService.toggleDebug()
|
||||||
|
|
||||||
|
method isDebugEnabled*[T](self: Controller[T]): bool =
|
||||||
|
return self.settingsService.isDebugEnabled()
|
||||||
|
|
|
@ -15,6 +15,12 @@ method toggleTelemetry*(self: AccessInterface) {.base.} =
|
||||||
method isTelemetryEnabled*(self: AccessInterface): bool {.base.} =
|
method isTelemetryEnabled*(self: AccessInterface): bool {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method toggleDebug*(self: AccessInterface) {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method isDebugEnabled*(self: AccessInterface): bool {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
type
|
type
|
||||||
## Abstract class (concept) which must be implemented by object/s used in this
|
## Abstract class (concept) which must be implemented by object/s used in this
|
||||||
## module.
|
## module.
|
||||||
|
|
|
@ -14,6 +14,9 @@ method isLoaded*(self: AccessInterface): bool {.base.} =
|
||||||
method toggleTelemetry*(self: AccessInterface) {.base.} =
|
method toggleTelemetry*(self: AccessInterface) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method toggleDebug*(self: AccessInterface) {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
# View Delegate Interface
|
# View Delegate Interface
|
||||||
# Delegate for the view must be declared here due to use of QtObject and multi
|
# Delegate for the view must be declared here due to use of QtObject and multi
|
||||||
# inheritance, which is not well supported in Nim.
|
# inheritance, which is not well supported in Nim.
|
||||||
|
|
|
@ -86,6 +86,7 @@ method load*[T](self: Module[T]) =
|
||||||
self.aboutModule.load()
|
self.aboutModule.load()
|
||||||
|
|
||||||
self.view.setIsTelemetryEnabled(self.controller.isTelemetryEnabled())
|
self.view.setIsTelemetryEnabled(self.controller.isTelemetryEnabled())
|
||||||
|
self.view.setIsDebugEnabled(self.controller.isDebugEnabled())
|
||||||
|
|
||||||
self.moduleLoaded = true
|
self.moduleLoaded = true
|
||||||
self.delegate.profileSectionDidLoad()
|
self.delegate.profileSectionDidLoad()
|
||||||
|
@ -98,3 +99,6 @@ method viewDidLoad*(self: Module) =
|
||||||
|
|
||||||
method toggleTelemetry*[T](self: Module[T]) =
|
method toggleTelemetry*[T](self: Module[T]) =
|
||||||
self.controller.toggleTelemetry()
|
self.controller.toggleTelemetry()
|
||||||
|
|
||||||
|
method toggleDebug*[T](self: Module[T]) =
|
||||||
|
self.controller.toggleDebug()
|
||||||
|
|
|
@ -8,6 +8,7 @@ QtObject:
|
||||||
delegate: io_interface.AccessInterface
|
delegate: io_interface.AccessInterface
|
||||||
# TODO: move to the correct module once all have been merged
|
# TODO: move to the correct module once all have been merged
|
||||||
isTelemetryEnabled: bool
|
isTelemetryEnabled: bool
|
||||||
|
isDebugEnabled: bool
|
||||||
|
|
||||||
proc setup(self: View) =
|
proc setup(self: View) =
|
||||||
self.QObject.setup
|
self.QObject.setup
|
||||||
|
@ -36,3 +37,20 @@ QtObject:
|
||||||
proc toggleTelemetry*(self: View) {.slot.} =
|
proc toggleTelemetry*(self: View) {.slot.} =
|
||||||
self.delegate.toggleTelemetry()
|
self.delegate.toggleTelemetry()
|
||||||
self.setIsTelemetryEnabled(not self.isTelemetryEnabled)
|
self.setIsTelemetryEnabled(not self.isTelemetryEnabled)
|
||||||
|
|
||||||
|
proc isDebugEnabledChanged*(self: View) {.signal.}
|
||||||
|
|
||||||
|
proc setIsDebugEnabled*(self: View, isDebugEnabled: bool) =
|
||||||
|
self.isDebugEnabled = isDebugEnabled
|
||||||
|
self.isDebugEnabledChanged()
|
||||||
|
|
||||||
|
proc getIsDebugEnabled*(self: View): QVariant {.slot.} =
|
||||||
|
return newQVariant(self.isDebugEnabled)
|
||||||
|
|
||||||
|
QtProperty[QVariant] isDebugEnabled:
|
||||||
|
read = getIsDebugEnabled
|
||||||
|
notify = isDebugEnabledChanged
|
||||||
|
|
||||||
|
proc toggleDebug*(self: View) {.slot.} =
|
||||||
|
self.delegate.toggleDebug()
|
||||||
|
self.setIsDebugEnabled(not self.isDebugEnabled)
|
||||||
|
|
|
@ -2,6 +2,7 @@ import # std libs
|
||||||
json, os
|
json, os
|
||||||
|
|
||||||
import utils
|
import utils
|
||||||
|
import chronicles
|
||||||
|
|
||||||
const GENERATED* = "generated"
|
const GENERATED* = "generated"
|
||||||
const SEED* = "seed"
|
const SEED* = "seed"
|
||||||
|
@ -122,7 +123,7 @@ var NODE_CONFIG* = %* {
|
||||||
#"ListenAddr": ":30304",
|
#"ListenAddr": ":30304",
|
||||||
"LogEnabled": true,
|
"LogEnabled": true,
|
||||||
"LogFile": "geth.log",
|
"LogFile": "geth.log",
|
||||||
"LogLevel": "INFO",
|
"LogLevel": $LogLevel.INFO,
|
||||||
"MailserversConfig": {
|
"MailserversConfig": {
|
||||||
"Enabled": true
|
"Enabled": true
|
||||||
},
|
},
|
||||||
|
|
|
@ -189,7 +189,7 @@ proc prepareAccountSettingsJsonObject(self: Service, account: GeneratedAccountDt
|
||||||
"wallet-root-address": account.derivedAccounts.walletRoot.address,
|
"wallet-root-address": account.derivedAccounts.walletRoot.address,
|
||||||
"preview-privacy?": true,
|
"preview-privacy?": true,
|
||||||
"signing-phrase": generateSigningPhrase(3),
|
"signing-phrase": generateSigningPhrase(3),
|
||||||
"log-level": "INFO",
|
"log-level": $LogLevel.INFO,
|
||||||
"latest-derived-path": 0,
|
"latest-derived-path": 0,
|
||||||
"networks/networks": DEFAULT_NETWORKS,
|
"networks/networks": DEFAULT_NETWORKS,
|
||||||
"currency": "usd",
|
"currency": "usd",
|
||||||
|
|
|
@ -88,3 +88,16 @@ method toggleTelemetry*(self: Service) =
|
||||||
method isTelemetryEnabled*(self: Service): bool =
|
method isTelemetryEnabled*(self: Service): bool =
|
||||||
let telemetryServerUrl = status_go_settings.getSetting[string](Setting.TelemetryServerUrl)
|
let telemetryServerUrl = status_go_settings.getSetting[string](Setting.TelemetryServerUrl)
|
||||||
return telemetryServerUrl != ""
|
return telemetryServerUrl != ""
|
||||||
|
|
||||||
|
method toggleDebug*(self: Service) =
|
||||||
|
var nodeConfig = status_go_settings.getNodeConfig()
|
||||||
|
if nodeConfig["LogLevel"].getStr() == $LogLevel.INFO:
|
||||||
|
nodeConfig["LogLevel"] = newJString($LogLevel.DEBUG)
|
||||||
|
else:
|
||||||
|
nodeConfig["LogLevel"] = newJString($LogLevel.INFO)
|
||||||
|
discard status_go_settings.saveSetting(Setting.NodeConfig, nodeConfig)
|
||||||
|
quit(QuitSuccess) # quits the app TODO: change this to logout instead when supported
|
||||||
|
|
||||||
|
method isDebugEnabled*(self: Service): bool =
|
||||||
|
let nodeConfig = status_go_settings.getNodeConfig()
|
||||||
|
return nodeConfig["LogLevel"].getStr() != $LogLevel.INFO
|
||||||
|
|
|
@ -53,3 +53,9 @@ method toggleTelemetry*(self: ServiceInterface) {.base.} =
|
||||||
|
|
||||||
method isTelemetryEnabled*(self: ServiceInterface): bool {.base.} =
|
method isTelemetryEnabled*(self: ServiceInterface): bool {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method toggleDebug*(self: ServiceInterface) {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method isDebugEnabled*(self: ServiceInterface): bool {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
|
@ -14,6 +14,8 @@ QtObject {
|
||||||
property var profileModelInst: profileModel
|
property var profileModelInst: profileModel
|
||||||
property var profileModuleInst: profileModule
|
property var profileModuleInst: profileModule
|
||||||
|
|
||||||
|
property bool isDebugEnabled: profileSectionModule.isDebugEnabled
|
||||||
|
|
||||||
property var activeCommunity: chatsModelInst.communities.activeCommunity
|
property var activeCommunity: chatsModelInst.communities.activeCommunity
|
||||||
|
|
||||||
function copyToClipboard(text) {
|
function copyToClipboard(text) {
|
||||||
|
|
|
@ -273,6 +273,17 @@ StatusPopupMenu {
|
||||||
enabled: isCurrentUser && !hideEmojiPicker && !emojiOnly && !isProfile && !isRightClickOnImage
|
enabled: isCurrentUser && !hideEmojiPicker && !emojiOnly && !isProfile && !isRightClickOnImage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StatusMenuItem {
|
||||||
|
id: copyMessageIdAction
|
||||||
|
text: qsTr("Copy Message Id")
|
||||||
|
icon.name: "chat"
|
||||||
|
enabled: store.isDebugEnabled
|
||||||
|
onTriggered: {
|
||||||
|
root.store.chatsModelInst.copyToClipboard(SelectedMessage.messageId)
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
StatusMenuItem {
|
StatusMenuItem {
|
||||||
id: pinAction
|
id: pinAction
|
||||||
text: {
|
text: {
|
||||||
|
|
|
@ -416,6 +416,15 @@ ScrollView {
|
||||||
openPopup(enableTelemetryConfirmationDialogComponent, {light: false})
|
openPopup(enableTelemetryConfirmationDialogComponent, {light: false})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StatusSettingsLineButton {
|
||||||
|
text: qsTr("Debug")
|
||||||
|
isSwitch: true
|
||||||
|
switchChecked: root.store.profileModuleInst.isDebugEnabled
|
||||||
|
onClicked: {
|
||||||
|
openPopup(enableDebugComponent)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworksModal {
|
NetworksModal {
|
||||||
|
@ -444,6 +453,26 @@ ScrollView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: enableDebugComponent
|
||||||
|
ConfirmationDialog {
|
||||||
|
property bool mode: false
|
||||||
|
|
||||||
|
id: confirmDialog
|
||||||
|
showCancelButton: true
|
||||||
|
confirmationText: qsTr("Are you sure you want to %1 debug mode? The app will be restarted for this change to take effect.").arg(root.store.profileModuleInst.isDebugEnabled ?
|
||||||
|
qsTr("disable") :
|
||||||
|
qsTr("enable"))
|
||||||
|
onConfirmButtonClicked: {
|
||||||
|
root.store.profileModuleInst.toggleDebug()
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
onCancelButtonClicked: {
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ConfirmationDialog {
|
ConfirmationDialog {
|
||||||
id: confirmationPopup
|
id: confirmationPopup
|
||||||
property string settingsProp: ""
|
property string settingsProp: ""
|
||||||
|
|
Loading…
Reference in New Issue