19#include <QLoggingCategory>
20Q_DECLARE_LOGGING_CATEGORY(UMBRELLO)
65 bool isEnabled(
const QString& name)
const;
66 void enable(
const QString& name);
67 void disable(
const QString& name);
74 static void registerClass(
const char * name,
bool state=
true,
const char *filePath =
nullptr);
77 void update(
const QString &name);
102 explicit Tracer(QWidget *parent =
nullptr);
106#define uDebug() qCDebug(UMBRELLO)
107#define uError() qCCritical(UMBRELLO)
108#define uWarning() qCWarning(UMBRELLO)
111#define DBG_SRC QString::fromLatin1(metaObject()->className())
113#define DEBUG_SHOW_FILTER() Tracer::instance()->show()
114#define DEBUG_N(latin1str) if (Tracer::instance()->logToConsole() || Tracer::instance()->isEnabled(latin1str)) uDebug()
115#define DEBUG() DEBUG_N(DBG_SRC)
116#define IS_DEBUG_ENABLED() Tracer::instance()->isEnabled(DBG_SRC)
117#define DEBUG_REGISTER(src) \
118 class src##Tracer { \
120 src##Tracer() { Tracer::registerClass(#src, true, __FILE__); } \
122 static src##Tracer src##TracerGlobal;
123#define DEBUG_REGISTER_DISABLED(src) \
124 class src##Tracer { \
126 src##Tracer() { Tracer::registerClass(#src, false, __FILE__); } \
128 static src##Tracer src##TracerGlobal;
130#define uIgnoreZeroPointer(a) if (!a) { uDebug() << "zero pointer detected" << __FILE__ << __LINE__; continue; }
139#define ENUM_NAME(o, e, v) (o::staticMetaObject.enumerator(o::staticMetaObject.indexOfEnumerator(#e)).valueToKey((v)))
152#define logDebug0(s) if (UMLApp::app()->logToConsole() || Tracer::instance()->isEnabled(DBG_SRC)) \
153 UMLApp::app()->logDebug(QStringLiteral(s))
154#define logInfo0(s) UMLApp::app()->logInfo(QStringLiteral(s))
155#define logWarn0(s) UMLApp::app()->logWarn(QStringLiteral(s))
156#define logError0(s) UMLApp::app()->logError(QStringLiteral(s))
158#define logDebug1(s, a) if (UMLApp::app()->logToConsole() || Tracer::instance()->isEnabled(DBG_SRC)) \
159 do { QString fmt = QString(QStringLiteral(s)).arg(a); UMLApp::app()->logDebug(fmt); } while (0)
160#define logInfo1(s, a) do { QString fmt = QString(QStringLiteral(s)).arg(a); UMLApp::app()->logInfo(fmt); } while (0)
161#define logWarn1(s, a) do { QString fmt = QString(QStringLiteral(s)).arg(a); UMLApp::app()->logWarn(fmt); } while (0)
162#define logError1(s, a) do { QString fmt = QString(QStringLiteral(s)).arg(a); UMLApp::app()->logError(fmt); } while (0)
164#define logDebug2(s, a, b) if (UMLApp::app()->logToConsole() || Tracer::instance()->isEnabled(DBG_SRC)) \
165 do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b); UMLApp::app()->logDebug(fmt); } while (0)
166#define logInfo2(s, a, b) do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b); UMLApp::app()->logInfo(fmt); } while (0)
167#define logWarn2(s, a, b) do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b); UMLApp::app()->logWarn(fmt); } while (0)
168#define logError2(s, a, b) do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b); UMLApp::app()->logError(fmt); } while (0)
170#define logDebug3(s, a, b, c) if (UMLApp::app()->logToConsole() || Tracer::instance()->isEnabled(DBG_SRC)) \
171 do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c); UMLApp::app()->logDebug(fmt); } while (0)
172#define logInfo3(s, a, b, c) do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c); UMLApp::app()->logInfo(fmt); } while (0)
173#define logWarn3(s, a, b, c) do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c); UMLApp::app()->logWarn(fmt); } while (0)
174#define logError3(s, a, b, c) do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c); UMLApp::app()->logError(fmt); } while (0)
176#define logDebug4(s, a, b, c, d) if (UMLApp::app()->logToConsole() || Tracer::instance()->isEnabled(DBG_SRC)) \
177 do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c).arg(d); UMLApp::app()->logDebug(fmt); } while (0)
178#define logInfo4(s, a, b, c, d) do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c).arg(d); UMLApp::app()->logInfo(fmt); } while (0)
179#define logWarn4(s, a, b, c, d) do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c).arg(d); UMLApp::app()->logWarn(fmt); } while (0)
180#define logError4(s, a, b, c, d) do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c).arg(d); UMLApp::app()->logError(fmt); } while (0)
182#define logDebug5(s, a, b, c, d, e) if (UMLApp::app()->logToConsole() || Tracer::instance()->isEnabled(DBG_SRC)) \
183 do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c).arg(d).arg(e); \
184 UMLApp::app()->logDebug(fmt); } while (0)
185#define logInfo5(s, a, b, c, d, e) do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c).arg(d).arg(e); \
186 UMLApp::app()->logInfo(fmt); } while (0)
187#define logWarn5(s, a, b, c, d, e) do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c).arg(d).arg(e); \
188 UMLApp::app()->logWarn(fmt); } while (0)
189#define logError5(s, a, b, c, d, e) do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c).arg(d).arg(e); \
190 UMLApp::app()->logError(fmt); } while (0)
192#define logDebug6(s, a, b, c, d, e, f) if (UMLApp::app()->logToConsole() || Tracer::instance()->isEnabled(DBG_SRC)) \
193 do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c).arg(d).arg(e).arg(f); UMLApp::app()->logDebug(fmt); } while (0)
Definition: debug_utils.h:86
MapEntry(const QString &_filePath, bool _state)
Definition: debug_utils.h:91
QString filePath
Definition: debug_utils.h:88
bool state
Definition: debug_utils.h:89
MapEntry()
Definition: debug_utils.h:90
The singleton class for switching on or off debug messages.
Definition: debug_utils.h:58
static StateMap * s_states
Definition: debug_utils.h:99
static bool s_logToConsole
Definition: debug_utils.h:100
void disable(const QString &name)
Definition: debug_utils.cpp:186
static Tracer * s_instance
Definition: debug_utils.h:97
void disableAll()
Definition: debug_utils.cpp:197
void enableAll()
Definition: debug_utils.cpp:192
void slotParentItemClicked(QTreeWidgetItem *parent)
Definition: debug_utils.cpp:299
QMap< QString, Qt::CheckState > StateMap
Definition: debug_utils.h:95
void updateParentItemCheckBox(QTreeWidgetItem *parent)
Definition: debug_utils.cpp:248
void enable(const QString &name)
Definition: debug_utils.cpp:176
~Tracer()
Definition: debug_utils.cpp:149
bool logToConsole()
Definition: debug_utils.cpp:202
static Tracer * instance()
Definition: debug_utils.cpp:109
void update(const QString &name)
Definition: debug_utils.cpp:233
bool isEnabled(const QString &name) const
Definition: debug_utils.cpp:158
static MapType * s_classes
Definition: debug_utils.h:98
static void registerClass(const char *name, bool state=true, const char *filePath=nullptr)
Definition: debug_utils.cpp:213
virtual void showEvent(QShowEvent *)
Definition: debug_utils.cpp:268
void slotItemClicked(QTreeWidgetItem *item, int column)
Definition: debug_utils.cpp:325
QMap< QString, MapEntry > MapType
Definition: debug_utils.h:94
QString toString(const T &value)
Definition: debug_utils.h:145