Skip to content

Commit

Permalink
Merge pull request #3518 from daschuer/logging
Browse files Browse the repository at this point in the history
Logging clean up
  • Loading branch information
uklotzde authored Jan 6, 2021
2 parents 3b2dbac + b6bf7c2 commit 02a2213
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/util/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,24 @@ QFile s_logfile;
// Whether to break on debug assertions.
bool s_debugAssertBreak = false;

// Note:
// you can customize this pattern by starting Mixxx with
// QT_MESSAGE_PATTERN="%{message}" mixxx
// For debugging timing related issues
// QT_MESSAGE_PATTERN="%{time yyyyMMdd h:mm:ss.zzz} %{type} [{{threadname}}] %{message}"
// Or for for finding the origin (in Debug builds)
// QT_MESSAGE_PATTERN="%{type} [{{threadname}}] %{file}:%{line} %{message}"
// QT_MESSAGE_PATTERN="%{type} [{{threadname}}] %{function} %{message}"
// TODO: Adjust the default format and messages and collect file and function info in release builds as well.

const QString kThreadNamePattern = QStringLiteral("{{threadname}}");
const QString kDefaultMessagePattern = QStringLiteral("%{type} [") +
kThreadNamePattern + QStringLiteral("] %{message}");

const QString kDefaultMessagePatternColor =
QStringLiteral(
"%{if-category}\033[35m %{category}:\033[35m%{endif}"
"%{if-debug}\033[34m%{type} \033[36m%{function}%{endif}"
"%{if-debug}\033[34m%{type}%{endif}"
"%{if-info}\033[32m%{type}%{endif}"
"%{if-warning}\033[93m%{type}%{endif}"
"%{if-critical}\033[91m%{type}%{endif}"
Expand Down Expand Up @@ -334,12 +344,10 @@ void Logging::initialize(

s_debugAssertBreak = debugAssertBreak;

if (qEnvironmentVariableIsEmpty("QT_MESSAGE_PATTERN")) {
if (CmdlineArgs::Instance().useColors()) {
qSetMessagePattern(kDefaultMessagePatternColor);
} else {
qSetMessagePattern(kDefaultMessagePattern);
}
if (CmdlineArgs::Instance().useColors()) {
qSetMessagePattern(kDefaultMessagePatternColor);
} else {
qSetMessagePattern(kDefaultMessagePattern);
}

// Install the Qt message handler.
Expand Down

0 comments on commit 02a2213

Please sign in to comment.