Implemented a debug logging feature that can be turned on/off from preferences

This commit is contained in:
2021-04-20 10:23:55 -05:00
parent 197e649afb
commit 1d9e6f8074
7 changed files with 12 additions and 4 deletions

View File

@@ -2,6 +2,7 @@
language = string(default="system")
use_proxy = boolean(default=False)
first_start = boolean(default=True)
debug_logging = boolean(default=False)
[sound]
volume = integer(default=100)

View File

@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import widgetUtils
from pubsub import pub
from wxUI.commonMessages import restart_program as restart_program_dialog
@@ -68,5 +67,6 @@ class configurationInteractor(base.baseInteractor):
self.presenter.update_app_setting(section="sound", setting="input_device", value=self.view.get_value("sound", "input"))
self.presenter.update_app_setting(section="sound", setting="output_device", value=self.view.get_value("sound", "output"))
self.presenter.update_app_setting(section="app-settings", setting="use_proxy", value=self.view.get_value("general", "use_proxy"))
self.presenter.update_app_setting(section="app-settings", setting="debug_logging", value=self.view.get_value("general", "debug_logging"))
self.presenter.save_app_settings_file()
self.presenter.save_settings_file()

View File

@@ -8,10 +8,11 @@ import sys
APP_LOG_FILE = 'debug.log'
ERROR_LOG_FILE = "error.log"
MESSAGE_FORMAT = "%(asctime)s %(name)s %(levelname)s: %(message)s"
DATE_FORMAT = "%d/%m/%Y %H:%M:%S"
DATE_FORMAT = "%d-%m-%Y %H:%M:%S"
formatter = logging.Formatter(MESSAGE_FORMAT, datefmt=DATE_FORMAT)
# Let's mute some really verbose logs.
requests_log = logging.getLogger("requests")
requests_log.setLevel(logging.WARNING)
urllib3 = logging.getLogger("urllib3")
@@ -24,7 +25,7 @@ logger.setLevel(logging.DEBUG)
app_handler = RotatingFileHandler(os.path.join(paths.logs_path(), APP_LOG_FILE), mode="w", encoding="utf-8")
app_handler.setFormatter(formatter)
app_handler.setLevel(logging.DEBUG)
app_handler.setLevel(logging.WARNING)
logger.addHandler(app_handler)
error_handler = logging.FileHandler(os.path.join(paths.logs_path(), ERROR_LOG_FILE), mode="w", encoding="utf-8")

View File

@@ -27,6 +27,8 @@ def setup():
global orig_session_init
log.debug("Starting Socializer %s" % (application.version,))
config.setup()
if config.app["app-settings"]["debug_logging"] == True:
logger.app_handler.setLevel(logging.DEBUG)
log.debug("Using %s %s" % (platform.system(), platform.architecture()[0]))
log.debug("Application path is %s" % (paths.app_path(),))
log.debug("config path is %s" % (paths.config_path(),))

View File

@@ -53,6 +53,7 @@ class configurationPresenter(base.basePresenter):
self.send_message("set_language", language=id)
self.send_message("set", tab="general", setting="load_images", value=self.session.settings["general"]["load_images"])
self.send_message("set", tab="general", setting="use_proxy", value=config.app["app-settings"]["use_proxy"])
self.send_message("set", tab="general", setting="debug_logging", value=config.app["app-settings"]["debug_logging"])
self.send_message("set", tab="general", setting="update_channel", value=self.get_update_channel_label(self.session.settings["general"]["update_channel"]))
self.send_message("create_tab", tab="buffers")
self.send_message("set", tab="buffers", setting="wall_buffer_count", value=self.session.settings["buffers"]["count_for_wall_buffers"])
@@ -89,7 +90,7 @@ class configurationPresenter(base.basePresenter):
raise AttributeError("The setting you specified is not present in the config file.")
# check if certain settings have been changed so we'd restart the client.
# List of app settings that require a restart after being changed.
settings_needing_restart = ["language", "use_proxy", "input_device", "output_device"]
settings_needing_restart = ["language", "use_proxy", "input_device", "output_device", "debug_logging"]
if value != config.app[section][setting] and setting in settings_needing_restart:
self.needs_restart = True
config.app[section][setting] = value

View File

@@ -16,6 +16,8 @@ class general(wx.Panel, widgetUtils.BaseDialog):
sizer.Add(self.load_images, 0, wx.ALL, 5)
self.use_proxy = wx.CheckBox(self, wx.NewId(), _("Use proxy"))
sizer.Add(self.use_proxy, 0, wx.ALL, 5)
self.debug_logging = wx.CheckBox(self, wx.NewId(), _("Enable debug logging (useful for reporting errors)"))
sizer.Add(self.debug_logging, 0, wx.ALL, 5)
lbl4 = wx.StaticText(self, wx.NewId(), _("Update channel"))
self.update_channel = wx.ComboBox(self, wx.NewId(), choices=[_("Stable"), _("Alpha")], value=_("Native"), style=wx.CB_READONLY)
box4 = wx.BoxSizer(wx.HORIZONTAL)