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 <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
This commit is contained in:
Thiago Macieira 2015-06-30 19:32:22 -07:00
parent 86a79260ca
commit 6388b30e79

View File

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