From 705ee1529679a658a6f2015a1b10a7d5a3596770 Mon Sep 17 00:00:00 2001 From: fwcd Date: Thu, 24 Aug 2023 15:46:16 +0200 Subject: [PATCH] Logging: Include timestamp in `mixxx.log` As per the discussion. Note that the stdout format can still be customized dynamically via the `QT_MESSAGE_PATTERN` environment variable. Co-authored-by: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com> --- src/util/logging.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/util/logging.cpp b/src/util/logging.cpp index 49d95445de5..c682cd80d30 100644 --- a/src/util/logging.cpp +++ b/src/util/logging.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -121,6 +122,8 @@ inline QString formatLogFileMessage( QtMsgType type, const QString& message, const QString& threadName) { + QString timestamp = QDateTime::currentDateTime().toString("hh:mm:ss.zzz"); + QString levelName; switch (type) { case QtDebugMsg: @@ -140,7 +143,7 @@ inline QString formatLogFileMessage( break; } - return levelName + QStringLiteral(" [") + threadName + QStringLiteral("] ") + message; + return QStringLiteral("%1 %2 [%3] %4").arg(timestamp, levelName, threadName, message); } /// Actually write a log message to a file.