From 14d311a781a5863832bee4cbac26e548280c4c2f Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 11 Oct 2019 12:59:59 +0200 Subject: Fix :debug-log-level without a console attached (cherry picked from commit 8ccea6e8000dbab70b66633167d3cea86e4de26e) --- doc/changelog.asciidoc | 1 + qutebrowser/misc/utilcmds.py | 5 ++++- qutebrowser/utils/log.py | 4 +--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc index a56a04694..fcf3d4718 100644 --- a/doc/changelog.asciidoc +++ b/doc/changelog.asciidoc @@ -37,6 +37,7 @@ Fixed relative basedirs. - Errors while reading the state file are now displayed instead of causing a crash. +- Crash when using `:debug-log-level` without a console attached. v1.8.1 (2019-09-27) ------------------- diff --git a/qutebrowser/misc/utilcmds.py b/qutebrowser/misc/utilcmds.py index 93cf20be8..cade12f0a 100644 --- a/qutebrowser/misc/utilcmds.py +++ b/qutebrowser/misc/utilcmds.py @@ -234,8 +234,11 @@ def debug_log_level(level: str) -> None: Args: level: The log level to set. """ + if log.console_handler is None: + raise cmdutils.CommandError("No log.console_handler. Not attached " + "to a console?") + log.change_console_formatter(log.LOG_LEVELS[level.upper()]) - assert log.console_handler is not None log.console_handler.setLevel(log.LOG_LEVELS[level.upper()]) diff --git a/qutebrowser/utils/log.py b/qutebrowser/utils/log.py index 168d5f52d..f1571566e 100644 --- a/qutebrowser/utils/log.py +++ b/qutebrowser/utils/log.py @@ -340,9 +340,7 @@ def change_console_formatter(level): Args: level: The numeric logging level """ - if not isinstance(console_handler.formatter, ColoredFormatter): - # JSON Formatter being used for end2end tests - pass + assert console_handler is not None use_colors = console_handler.formatter.use_colors console_fmt = get_console_format(level) -- cgit v1.2.3-54-g00ecf