Fix the %{time} printing to *not* default to the process's time
The default should be the actual time of day. Showing the process's time is the optional case. In the future, we'll provide a way to showing the monotonic reference time ("boot") and we should improve the detection of actual application runtime. Change-Id: I41936d77ab9fad2073dc0ce1c97cabe57ec39f16 Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
This commit is contained in:
parent
0792943d59
commit
bb07737614
5
dist/changes-5.4.0
vendored
5
dist/changes-5.4.0
vendored
@ -97,6 +97,11 @@ QtCore
|
|||||||
|
|
||||||
- Logging:
|
- Logging:
|
||||||
* QT_MESSAGE_PATTERN can include a backtrace using %{backtrace}
|
* QT_MESSAGE_PATTERN can include a backtrace using %{backtrace}
|
||||||
|
* QT_MESSAGE_PATTERN can include a timestamp using %{time}. By
|
||||||
|
default, this shows the time in ISO format (YYYY-MM-DDTHH:mm:ss),
|
||||||
|
but a different format string can be specified in the tag (e.g.,
|
||||||
|
%{time YYYYMMDDHHmmsszzz}). If the format is "process", Qt will
|
||||||
|
display the elapsed time since the process started.
|
||||||
* Added QtMsgType argument to QLoggingCategory constructor and
|
* Added QtMsgType argument to QLoggingCategory constructor and
|
||||||
Q_LOGGING_CATEGORY macro that controls the default category
|
Q_LOGGING_CATEGORY macro that controls the default category
|
||||||
configuration.
|
configuration.
|
||||||
|
@ -1201,11 +1201,14 @@ QString qFormatLogMessage(QtMsgType type, const QMessageLogContext &context, con
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else if (token == timeTokenC) {
|
} else if (token == timeTokenC) {
|
||||||
quint64 ms = pattern->timer.elapsed();
|
if (pattern->timeFormat == QLatin1String("process")) {
|
||||||
if (pattern->timeFormat.isEmpty())
|
quint64 ms = pattern->timer.elapsed();
|
||||||
message.append(QString().sprintf("%6d.%03d", uint(ms / 1000), uint(ms % 1000)));
|
message.append(QString().sprintf("%6d.%03d", uint(ms / 1000), uint(ms % 1000)));
|
||||||
else
|
} else if (pattern->timeFormat.isEmpty()) {
|
||||||
message.append(pattern->startTime.addMSecs(ms).toString(pattern->timeFormat));
|
message.append(QDateTime::currentDateTime().toString(Qt::ISODate));
|
||||||
|
} else {
|
||||||
|
message.append(QDateTime::currentDateTime().toString(pattern->timeFormat));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
} else if (token == ifCategoryTokenC) {
|
} else if (token == ifCategoryTokenC) {
|
||||||
if (!context.category || (strcmp(context.category, "default") == 0))
|
if (!context.category || (strcmp(context.category, "default") == 0))
|
||||||
@ -1550,9 +1553,10 @@ void qErrnoWarning(int code, const char *msg, ...)
|
|||||||
\row \li \c %{pid} \li QCoreApplication::applicationPid()
|
\row \li \c %{pid} \li QCoreApplication::applicationPid()
|
||||||
\row \li \c %{threadid} \li ID of current thread
|
\row \li \c %{threadid} \li ID of current thread
|
||||||
\row \li \c %{type} \li "debug", "warning", "critical" or "fatal"
|
\row \li \c %{type} \li "debug", "warning", "critical" or "fatal"
|
||||||
\row \li \c %{time} \li time of the message, in seconds since the process started
|
\row \li \c %{time process} \li time of the message, in seconds since the process started (the token "process" is literal)
|
||||||
\row \li \c %{time format} \li system time when the message occurred, formatted by
|
\row \li \c %{time [format]} \li system time when the message occurred, formatted by
|
||||||
passing the \c format to \l QDateTime::toString()
|
passing the \c format to \l QDateTime::toString(). If the format is
|
||||||
|
not specified, the format of Qt::ISODate is used.
|
||||||
\row \li \c{%{backtrace [depth=N] [separator="..."]}} \li A backtrace with the number of frames
|
\row \li \c{%{backtrace [depth=N] [separator="..."]}} \li A backtrace with the number of frames
|
||||||
specified by the optional \c depth parameter (defaults to 5), and separated by the optional
|
specified by the optional \c depth parameter (defaults to 5), and separated by the optional
|
||||||
\c separator parameter (defaults to "|").
|
\c separator parameter (defaults to "|").
|
||||||
|
@ -765,7 +765,7 @@ void tst_qmessagehandler::qMessagePattern_data()
|
|||||||
|
|
||||||
// %{time} should have a padding of 6 so if it takes less than 10 seconds to show
|
// %{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
|
// the first message, there should be 5 spaces
|
||||||
QTest::newRow("time") << "<%{time}>%{message}" << true << (QList<QByteArray>()
|
QTest::newRow("time-process") << "<%{time process}>%{message}" << true << (QList<QByteArray>()
|
||||||
<< "< ");
|
<< "< ");
|
||||||
|
|
||||||
#ifdef __GLIBC__
|
#ifdef __GLIBC__
|
||||||
|
Loading…
x
Reference in New Issue
Block a user