From 6388b30e79e315262aef95c9825eaaffdfdd9d54 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 30 Jun 2015 19:32:22 -0700 Subject: [PATCH] Fix the printing of the ms-since-boot in %{time boot} Commit 5d366f7e was not correct. The time displayed would always be the same (the start time of the application). [ChangeLog][QtCore][Logging framework] Fixed a bug that would cause a "%{time boot}" field in the logging framework's pattern to always display the same value, instead of the time since boot. Change-Id: I255870833a024a36adf6ffff13ecb1dca4a688ed Reviewed-by: Friedemann Kleint Reviewed-by: Kai Koehne --- src/corelib/global/qlogging.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 0846d2a6db..fca8656f9b 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -1359,8 +1359,9 @@ QString qFormatLogMessage(QtMsgType type, const QMessageLogContext &context, con } else if (pattern->timeFormat == QLatin1String("boot")) { // just print the milliseconds since the elapsed timer reference // like the Linux kernel does - pattern->timer.elapsed(); - uint ms = pattern->timer.msecsSinceReference(); + QElapsedTimer now; + now.start(); + uint ms = now.msecsSinceReference(); message.append(QString::asprintf("%6d.%03d", uint(ms / 1000), uint(ms % 1000))); } else if (pattern->timeFormat.isEmpty()) { message.append(QDateTime::currentDateTime().toString(Qt::ISODate));