1 #pragma once 2 3 #include <QDebug> 4 5 // Specifies whether or not we should dump incoming data to the console at 6 // runtime. This is useful for end-user debugging and script-writing. 7 class ControllerDebug { 8 public: 9 // Any debug statement starting with this prefix bypasses the --logLevel 10 // command line flags. 11 static constexpr const char kLogMessagePrefix[] = "CDBG"; 12 static constexpr int kLogMessagePrefixLength = sizeof(kLogMessagePrefix) - 1; 13 14 static bool enabled(); 15 16 // Override the command-line argument (for testing) enable()17 static void enable() { 18 s_enabled = true; 19 } 20 21 private: 22 ControllerDebug() = delete; 23 24 static bool s_enabled; 25 }; 26 27 // Usage: controllerDebug("hello" << "world"); 28 // 29 // We prefix every log message with Logging::kControllerDebugPrefix so that we 30 // can bypass the --logLevel commandline argument when --controllerDebug is 31 // specified. 32 // 33 // In order of Bug #1797746, since transition to qt5 it is needed unquote the 34 // output for mixxx.log with .noquote(), because in qt5 QDebug() is quoted by default. 35 #define controllerDebug(stream) \ 36 { \ 37 if (ControllerDebug::enabled()) { \ 38 QDebug(QtDebugMsg).noquote() << ControllerDebug::kLogMessagePrefix << stream; \ 39 } \ 40 } 41