Added option to enable debug logging

This commit is contained in:
Mark Qvist 2022-12-19 02:06:41 +01:00
parent 3e0d2bee8b
commit 0abf26d60c
4 changed files with 43 additions and 2 deletions

View File

@ -1267,6 +1267,10 @@ class SidebandApp(MDApp):
self.sideband.config["lxmf_sync_limit"] = self.root.ids.settings_lxmf_sync_limit.active
self.sideband.save_configuration()
def save_debug(sender=None, event=None):
self.sideband.config["debug"] = self.root.ids.settings_debug.active
self.sideband.save_configuration()
def save_print_command(sender=None, event=None):
if not sender.focus:
in_cmd = self.root.ids.settings_print_command.text
@ -1345,7 +1349,6 @@ class SidebandApp(MDApp):
self.root.ids.settings_lxmf_sync_interval.value = self.sideband.config["lxmf_sync_interval"]
sync_interval_change(save=False)
if self.sideband.config["lxmf_sync_limit"] == None or self.sideband.config["lxmf_sync_limit"] == False:
sync_limit = False
else:
@ -1353,6 +1356,10 @@ class SidebandApp(MDApp):
self.root.ids.settings_lxmf_sync_limit.active = sync_limit
self.root.ids.settings_lxmf_sync_limit.bind(active=save_lxmf_sync_limit)
self.root.ids.settings_debug.active = self.sideband.config["debug"]
self.root.ids.settings_debug.bind(active=save_debug)
self.settings_ready = True
def close_settings_action(self, sender=None):

View File

@ -128,6 +128,10 @@ class SidebandService():
self.sideband = SidebandCore(self, is_service=True, android_app_dir=self.app_dir, verbose=__debug_build__)
self.sideband.service_context = self.android_service
self.sideband.owner_service = self
if self.sideband.config["debug"]:
Logger.setLevel(LOG_LEVELS["debug"])
self.sideband.start()
self.update_connectivity_type()

View File

@ -122,6 +122,7 @@ class SidebandCore():
self.identity_path = self.app_dir+"/app_storage/primary_identity"
self.db_path = self.app_dir+"/app_storage/sideband.db"
self.lxmf_storage = self.app_dir+"/app_storage/"
self.log_dir = self.app_dir+"/app_storage/"
self.tmp_dir = self.app_dir+"/app_storage/tmp"
self.exports_dir = self.app_dir+"/exports"
@ -137,6 +138,9 @@ class SidebandCore():
self.__load_config()
self.first_run = False
if self.config["debug"]:
self.log_verbose = True
if not os.path.isdir(self.tmp_dir):
os.makedirs(self.tmp_dir)
else:
@ -203,6 +207,7 @@ class SidebandCore():
self.config = {}
# Settings
self.config["debug"] = False
self.config["display_name"] = "Anonymous Peer"
self.config["notifications_on"] = True
self.config["dark_ui"] = False
@ -300,6 +305,8 @@ class SidebandCore():
config_file.close()
# Migration actions from earlier config formats
if not "debug" in self.config:
self.config["debug"] = False
if not "dark_ui" in self.config:
self.config["dark_ui"] = True
if not "lxmf_periodic_sync" in self.config:
@ -1389,6 +1396,13 @@ class SidebandCore():
self.reticulum = RNS.Reticulum(configdir=self.rns_configdir, loglevel=selected_level)
if RNS.vendor.platformutils.get_platform() == "android":
if self.config["debug"]:
self.reticulum.logdest = RNS.LOG_FILE
if not self.reticulum.is_connected_to_shared_instance:
self.reticulum.logfile = self.log_dir+"sideband_service.log"
else:
self.reticulum.logfile = self.log_dir+"sideband_core.log"
if not self.reticulum.is_connected_to_shared_instance:
RNS.log("Running as master or standalone instance, adding interfaces")

View File

@ -1085,7 +1085,7 @@ MDNavigationLayout:
height: dp(48)
MDLabel:
text: "Announce At App Startup"
text: "Announce Automatically"
font_style: "H6"
MDSwitch:
@ -1189,6 +1189,22 @@ MDNavigationLayout:
disabled: True
active: False
MDBoxLayout:
orientation: "horizontal"
size_hint_y: None
padding: [0,0,dp(24),dp(0)]
height: dp(48)
MDLabel:
text: "Debug Logging"
font_style: "H6"
MDSwitch:
id: settings_debug
pos_hint: {"center_y": 0.3}
disabled: False
active: False
MDScreen:
name: "hardware_screen"