summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qutebrowser/utils/log.py14
-rw-r--r--tests/end2end/test_invocations.py11
2 files changed, 20 insertions, 5 deletions
diff --git a/qutebrowser/utils/log.py b/qutebrowser/utils/log.py
index b6f1f3e9b..2fb64eddd 100644
--- a/qutebrowser/utils/log.py
+++ b/qutebrowser/utils/log.py
@@ -363,12 +363,16 @@ def change_console_formatter(level: int) -> None:
level: The numeric logging level
"""
assert console_handler is not None
+ old_formatter = console_handler.formatter
- old_formatter = cast(ColoredFormatter, console_handler.formatter)
- console_fmt = get_console_format(level)
- console_formatter = ColoredFormatter(console_fmt, DATEFMT, '{',
- use_colors=old_formatter.use_colors)
- console_handler.setFormatter(console_formatter)
+ if isinstance(old_formatter, ColoredFormatter):
+ console_fmt = get_console_format(level)
+ console_formatter = ColoredFormatter(
+ console_fmt, DATEFMT, '{', use_colors=old_formatter.use_colors)
+ console_handler.setFormatter(console_formatter)
+ else:
+ # Same format for all levels
+ assert isinstance(old_formatter, JSONFormatter), old_formatter
def qt_message_handler(msg_type: QtCore.QtMsgType,
diff --git a/tests/end2end/test_invocations.py b/tests/end2end/test_invocations.py
index 1ce22b7ea..076ebb2bd 100644
--- a/tests/end2end/test_invocations.py
+++ b/tests/end2end/test_invocations.py
@@ -743,3 +743,14 @@ def test_unavailable_backend(request, quteproc_new):
message=('*qutebrowser tried to start with the Qt* backend but failed '
'because * could not be imported.*'))
line.expected = True
+
+
+def test_json_logging_without_debug(request, quteproc_new):
+ args = _base_args(request.config) + ['--temp-basedir', ':quit']
+ args.remove('--debug')
+ args.remove('about:blank') # interfers with :quit at the end
+
+ quteproc_new.exit_expected = True
+ quteproc_new.start(args)
+ assert not quteproc_new.is_running()
+ assert not quteproc_new.captured_log