Quote weird Qt functions for logging.

This commit is contained in:
Florian Bruhin 2015-11-09 19:55:05 +01:00
parent d288c9598d
commit 6579866abe
3 changed files with 33 additions and 3 deletions

View File

@ -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:

View File

@ -68,7 +68,9 @@ class LogLine(testprocess.Line):
(?P<timestamp>\d\d:\d\d:\d\d)
\ (?P<loglevel>VDEBUG|DEBUG|INFO|WARNING|ERROR)
\ +(?P<category>\w+)
\ +(?P<module>(\w+|Unknown\ module)):(?P<function>\w+):(?P<line>\d+)
\ +(?P<module>(\w+|Unknown\ module)):
(?P<function>[^"][^:]*|"[^"]+"):
(?P<line>\d+)
\ (?P<message>.+)
""", 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:

View File

@ -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)