From 7e3d1ccd2437f4cd34595141bfb0ef3e650bd8ea Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 19 Aug 2016 15:08:15 +0200 Subject: [PATCH] Simplify :debug-log-filter implementation --- qutebrowser/misc/utilcmds.py | 4 +--- qutebrowser/utils/log.py | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/qutebrowser/misc/utilcmds.py b/qutebrowser/misc/utilcmds.py index dcb1ce7d0..20fce5e47 100644 --- a/qutebrowser/misc/utilcmds.py +++ b/qutebrowser/misc/utilcmds.py @@ -270,9 +270,7 @@ def debug_log_filter(filters: str): filters: log filters for console log. """ if set(filters.split(',')).issubset(log.LOGGER_NAMES): - log.console_handler.removeFilter(log.console_filter) - log.console_filter = log.LogFilter(filters.split(',')) - log.console_handler.addFilter(log.console_filter) + log.console_filter.names = filters.split(',') else: raise cmdexc.CommandError("filters: Invalid value {} - expected one " "of: {}".format(filters, diff --git a/qutebrowser/utils/log.py b/qutebrowser/utils/log.py index badf719bf..1ee91bad5 100644 --- a/qutebrowser/utils/log.py +++ b/qutebrowser/utils/log.py @@ -467,16 +467,16 @@ class LogFilter(logging.Filter): def __init__(self, names): super().__init__() - self._names = names + self.names = names def filter(self, record): """Determine if the specified record is to be logged.""" - if self._names is None: + if self.names is None: return True if record.levelno > logging.DEBUG: # More important than DEBUG, so we won't filter at all return True - for name in self._names: + for name in self.names: if record.name == name: return True elif not record.name.startswith(name):