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