Skip to content

Commit

Permalink
Logging: Include timestamp in mixxx.log
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
fwcd and Swiftb0y committed Aug 28, 2023
1 parent 252ece3 commit 705ee15
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/util/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <stdio.h>

#include <QByteArray>
#include <QDateTime>
#include <QFile>
#include <QFileInfo>
#include <QIODevice>
Expand Down Expand Up @@ -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:
Expand All @@ -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.
Expand Down

0 comments on commit 705ee15

Please sign in to comment.