From 322d97c3fadac85c629b02c923b7b48df4f23521 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 28 Sep 2017 21:30:32 +0200 Subject: [PATCH] Only show warning message stack with --debug --- qutebrowser/utils/log.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/qutebrowser/utils/log.py b/qutebrowser/utils/log.py index fa0208ea7..98f14a454 100644 --- a/qutebrowser/utils/log.py +++ b/qutebrowser/utils/log.py @@ -39,6 +39,7 @@ except ImportError: colorama = None _log_inited = False +_args = None COLORS = ['black', 'red', 'green', 'yellow', 'blue', 'purple', 'cyan', 'white'] COLOR_ESCAPES = {color: '\033[{}m'.format(i) @@ -189,8 +190,9 @@ def init_log(args): logging.captureWarnings(True) _init_py_warnings() QtCore.qInstallMessageHandler(qt_message_handler) - global _log_inited + global _log_inited, _args _log_inited = True + _args = args def _init_py_warnings(): @@ -442,7 +444,11 @@ def qt_message_handler(msg_type, context, msg): msg += ("\n\nOn Archlinux, this should fix the problem:\n" " pacman -S libxkbcommon-x11") faulthandler.disable() - stack = ''.join(traceback.format_stack()) + + if _args.debug: + stack = ''.join(traceback.format_stack()) + else: + stack = None record = qt.makeRecord(name, level, context.file, context.line, msg, None, None, func, sinfo=stack) qt.handle(record)