Skip to content

Commit b619e2b

Browse files
authored
Merge pull request #8003 from SomberNight/202210_android_debug_logs
android: add setting to enable debug logs
2 parents 656fd1b + 34b594e commit b619e2b

File tree

6 files changed

+43
-1
lines changed

6 files changed

+43
-1
lines changed

electrum/gui/kivy/main_window.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ def on_use_gossip(self, instance, x):
208208
self.network.run_from_another_thread(
209209
self.network.stop_gossip())
210210

211+
enable_debug_logs = BooleanProperty(False)
212+
def on_enable_debug_logs(self, instance, x):
213+
self.electrum_config.set_key('gui_enable_debug_logs', self.enable_debug_logs, True)
214+
211215
use_change = BooleanProperty(False)
212216
def on_use_change(self, instance, x):
213217
if self.wallet:
@@ -435,6 +439,7 @@ def __init__(self, **kwargs):
435439
self.use_rbf = config.get('use_rbf', True)
436440
self.use_gossip = config.get('use_gossip', False)
437441
self.use_unconfirmed = not config.get('confirmed_only', False)
442+
self.enable_debug_logs = config.get('gui_enable_debug_logs', False)
438443

439444
# create triggers so as to minimize updating a max of 2 times a sec
440445
self._trigger_update_wallet = Clock.create_trigger(self.update_wallet, .5)

electrum/gui/kivy/uix/dialogs/settings.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,13 @@
102102
title: _('Lightning Routing') + ': ' + self.status
103103
description: _("Use trampoline routing or gossip.")
104104
action: partial(root.routing_dialog, self)
105+
CardSeparator
106+
SettingsItem:
107+
disabled: bool(app.electrum_config.get('verbosity')) and not app.enable_debug_logs
108+
status: 'ON' if (bool(app.electrum_config.get('verbosity')) or app.enable_debug_logs) else 'OFF'
109+
title: _('Enable debug logs') + ': ' + self.status
110+
description: "(developer) Log to stderr, to inspect with logcat."
111+
action: partial(root.boolean_dialog, 'enable_debug_logs', _('Debug Logs'), self.description)
105112
106113
# disabled: there is currently only one coin selection policy
107114
#CardSeparator

electrum/gui/qml/components/Preferences.qml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,17 @@ Pane {
235235
}
236236
}
237237

238+
Switch {
239+
id: enableDebugLogs
240+
text: qsTr('Enable debug logs (for developers)')
241+
Layout.columnSpan: 2
242+
onCheckedChanged: {
243+
if (activeFocus)
244+
Config.enableDebugLogs = checked
245+
}
246+
enabled: Config.canToggleDebugLogs
247+
}
248+
238249
}
239250

240251
}
@@ -257,6 +268,7 @@ Pane {
257268
spendUnconfirmed.checked = Config.spendUnconfirmed
258269
lnRoutingType.currentIndex = Config.useGossip ? 0 : 1
259270
useFallbackAddress.checked = Config.useFallbackAddress
271+
enableDebugLogs.checked = Config.enableDebugLogs
260272
useRbf.checked = Config.useRbf
261273
}
262274
}

electrum/gui/qml/qeconfig.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,22 @@ def useFallbackAddress(self, use_fallback):
130130
self.config.set_key('bolt11_fallback', use_fallback)
131131
self.useFallbackAddressChanged.emit()
132132

133+
enableDebugLogsChanged = pyqtSignal()
134+
@pyqtProperty(bool, notify=enableDebugLogsChanged)
135+
def enableDebugLogs(self):
136+
gui_setting = self.config.get('gui_enable_debug_logs', False)
137+
return gui_setting or bool(self.config.get('verbosity'))
138+
139+
@pyqtProperty(bool, notify=enableDebugLogsChanged)
140+
def canToggleDebugLogs(self):
141+
gui_setting = self.config.get('gui_enable_debug_logs', False)
142+
return not self.config.get('verbosity') or gui_setting
143+
144+
@enableDebugLogs.setter
145+
def enableDebugLogs(self, enable):
146+
self.config.set_key('gui_enable_debug_logs', enable)
147+
self.enableDebugLogsChanged.emit()
148+
133149
useRbfChanged = pyqtSignal()
134150
@pyqtProperty(bool, notify=useRbfChanged)
135151
def useRbf(self):

electrum/logging.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,9 @@ def configure_logging(config: 'SimpleConfig', *, log_to_file: Optional[bool] = N
314314

315315
verbosity = config.get('verbosity')
316316
verbosity_shortcuts = config.get('verbosity_shortcuts')
317+
if not verbosity:
318+
if config.get('gui_enable_debug_logs') or is_android_debug_apk():
319+
verbosity = '*'
317320
_configure_stderr_logging(verbosity=verbosity, verbosity_shortcuts=verbosity_shortcuts)
318321

319322
if log_to_file is None:

run_electrum

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,6 @@ def main():
325325
import importlib.util
326326
android_gui = 'kivy' if importlib.util.find_spec('kivy') else 'qml'
327327
config_options = {
328-
'verbosity': '*' if util.is_android_debug_apk() else '',
329328
'cmd': 'gui',
330329
'gui': android_gui,
331330
'single_password':True,

0 commit comments

Comments
 (0)