From 6579866abed780438093ecbd6ab29f45c1fbdc0a Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 9 Nov 2015 19:55:05 +0100 Subject: [PATCH] Quote weird Qt functions for logging. --- qutebrowser/utils/log.py | 4 ++++ tests/integration/quteprocess.py | 6 ++++-- tests/integration/test_quteprocess.py | 26 +++++++++++++++++++++++++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/qutebrowser/utils/log.py b/qutebrowser/utils/log.py index 2a87cab4c..2d615e4b3 100644 --- a/qutebrowser/utils/log.py +++ b/qutebrowser/utils/log.py @@ -320,10 +320,14 @@ def qt_message_handler(msg_type, context, msg): level = logging.DEBUG else: level = qt_to_logging[msg_type] + if context.function is None: func = 'none' + elif ':' in context.function: + func = '"{}"'.format(context.function) else: func = context.function + if context.category is None or context.category == 'default': name = 'qt' else: diff --git a/tests/integration/quteprocess.py b/tests/integration/quteprocess.py index 592ef99ce..8989d3911 100644 --- a/tests/integration/quteprocess.py +++ b/tests/integration/quteprocess.py @@ -68,7 +68,9 @@ class LogLine(testprocess.Line): (?P\d\d:\d\d:\d\d) \ (?PVDEBUG|DEBUG|INFO|WARNING|ERROR) \ +(?P\w+) - \ +(?P(\w+|Unknown\ module)):(?P\w+):(?P\d+) + \ +(?P(\w+|Unknown\ module)): + (?P[^"][^:]*|"[^"]+"): + (?P\d+) \ (?P.+) """, re.VERBOSE) @@ -98,7 +100,7 @@ class LogLine(testprocess.Line): if function == 'none': self.function = None else: - self.function = function + self.function = function.strip('"') line = int(match.group('line')) if self.function is None and line == 0: diff --git a/tests/integration/test_quteprocess.py b/tests/integration/test_quteprocess.py index 495e7438b..a301b5115 100644 --- a/tests/integration/test_quteprocess.py +++ b/tests/integration/test_quteprocess.py @@ -74,7 +74,31 @@ def test_qt_log_ignore(qtbot, quteproc): # Expected message '00:00:00 VDEBUG foo foo:foo:0 SpellCheck: test', {'expected': True}, - ) + ), + ( + # Weird Qt location + '00:00:00 DEBUG qt qnetworkreplyhttpimpl:"void ' + 'QNetworkReplyHttpImplPrivate::error(QNetworkReply::NetworkError, ' + 'const QString&)":1929 QNetworkReplyImplPrivate::error: Internal ' + 'problem, this method must only be called once.', + { + 'module': 'qnetworkreplyhttpimpl', + 'function': 'void QNetworkReplyHttpImplPrivate::error(' + 'QNetworkReply::NetworkError, const QString&)', + 'line': 1929 + } + ), + ( + '00:00:00 WARNING qt qxcbxsettings:"QXcbXSettings::' + 'QXcbXSettings(QXcbScreen*)":233 ' + 'QXcbXSettings::QXcbXSettings(QXcbScreen*) Failed to get selection ' + 'owner for XSETTINGS_S atom ', + { + 'module': 'qxcbxsettings', + 'function': 'QXcbXSettings::QXcbXSettings(QXcbScreen*)', + 'line': 233, + } + ), ]) def test_log_line_parse(data, attrs): line = quteprocess.LogLine(data)