diff --git a/changelog.md b/changelog.md index 01e6887..30037ff 100644 --- a/changelog.md +++ b/changelog.md @@ -6,6 +6,7 @@ * It is now possible to read an article from a wall post. The article will be opened in a new dialog. This might work better in countries where VK is blocked as users no longer need to open the web browser. Unfortunately, as articles are mainly undocumented in the API, it is not possible to perform other actions besides reading them from Socializer. * the spelling correction module is able to add words to the dictionary so it will learn which words should start to ignore. +* Added a new setting, in the preferences dialog, that allows you to turn on the debug logging feature. With this feature Enabled, Socializer will log more information regarding what is doing while an error occurs. This feature must be enabled when you want to report an issue and send us your logs. ### bugfixes diff --git a/src/app-configuration.defaults b/src/app-configuration.defaults index cbdc967..90b8973 100644 --- a/src/app-configuration.defaults +++ b/src/app-configuration.defaults @@ -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) diff --git a/src/interactors/configuration.py b/src/interactors/configuration.py index a300cfd..fc164dd 100644 --- a/src/interactors/configuration.py +++ b/src/interactors/configuration.py @@ -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() diff --git a/src/logger.py b/src/logger.py index d25ac75..bf37121 100644 --- a/src/logger.py +++ b/src/logger.py @@ -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") diff --git a/src/main.py b/src/main.py index 4cf621d..5502843 100644 --- a/src/main.py +++ b/src/main.py @@ -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(),)) diff --git a/src/presenters/configuration.py b/src/presenters/configuration.py index a008c62..c70aecd 100644 --- a/src/presenters/configuration.py +++ b/src/presenters/configuration.py @@ -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 diff --git a/src/views/dialogs/configuration.py b/src/views/dialogs/configuration.py index f4014f5..0726c16 100644 --- a/src/views/dialogs/configuration.py +++ b/src/views/dialogs/configuration.py @@ -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)