From 705d29585b9a006b2fc8dd77ebf7a67b3670011b Mon Sep 17 00:00:00 2001 From: "M. Moellney" Date: Sat, 19 Mar 2016 22:00:32 +0100 Subject: Fix qSetMessagePattern to have many time/backtrace parts The previous implementation overwrote multiple 'time' parts in the qSetMessagePattern with the last setting in the pattern line. %{time}%{time process}%{time boot} ended up to be output as if %{time boot}%{time boot}%{time boot} was set. This fix keeps the arguments of each individual 'time' part. The same holds for multiple 'backtrace' parts. The previouse implementation overwrote multiple 'backtrace' arguments with the arguments of the last occurrence. This fix keeps the individual arguments for the 'process' parts. The individual arguments are applied in qFormatLogMessage. A new test to verify the individual 'time' arguments application is added, too. Task-number: QTBUG-51944 Change-Id: Ib757614a482c5f31ed0a61b550daa2eea4b907b4 Reviewed-by: Olivier Goffart (Woboq GmbH) --- tests/auto/corelib/global/qlogging/tst_qlogging.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/auto/corelib/global/qlogging/tst_qlogging.cpp') diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp index a65a72313f..618806f3cd 100644 --- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp @@ -779,6 +779,17 @@ void tst_qmessagehandler::qMessagePattern_data() << true << (QList() << ('/' + QDateTime::currentDateTime().toString("yyyy - MM - d").toUtf8() + "/qDebug")); + QTest::newRow("time-time") << "/%{time yyyy - MM - d}/%{time dd-MM-yy}/%{message}" + << true << (QList() + << ('/' + QDateTime::currentDateTime().toString("yyyy - MM - d").toUtf8() + + '/' + QDateTime::currentDateTime().toString("dd-MM-yy").toUtf8() + + "/qDebug")); + + QTest::newRow("skipped-time-shown-time") + << "/%{if-warning}%{time yyyy - MM - d}%{endif}%{if-debug}%{time dd-MM-yy}%{endif}/%{message}" + << true << (QList() + << ('/' + QDateTime::currentDateTime().toString("dd-MM-yy").toUtf8() + "/qDebug")); + // %{time} should have a padding of 6 so if it takes less than 10 seconds to show // the first message, there should be 5 spaces QTest::newRow("time-process") << "<%{time process}>%{message}" << true << (QList() -- cgit v1.2.3