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);
104 explicit Tracer(QWidget *parent =
nullptr);
108#define uDebug() qCDebug(UMBRELLO)
109#define uError() qCCritical(UMBRELLO)
110#define uWarning() qCWarning(UMBRELLO)
113#define DBG_SRC QString::fromLatin1(metaObject()->className())
115#define DEBUG_SHOW_FILTER() Tracer::instance()->show()
116#define DEBUG_N(latin1str) if (Tracer::instance()->logToConsole() || Tracer::instance()->isEnabled(latin1str)) uDebug()
117#define DEBUG() DEBUG_N(DBG_SRC)
118#define IS_DEBUG_ENABLED() Tracer::instance()->isEnabled(DBG_SRC)
119#define DEBUG_REGISTER(src) \
120 class src##Tracer { \
122 src##Tracer() { Tracer::registerClass(#src, true, __FILE__); } \
124 static src##Tracer src##TracerGlobal;
125#define DEBUG_REGISTER_DISABLED(src) \
126 class src##Tracer { \
128 src##Tracer() { Tracer::registerClass(#src, false, __FILE__); } \
130 static src##Tracer src##TracerGlobal;
132#define uIgnoreZeroPointer(a) if (!a) { uDebug() << "zero pointer detected" << __FILE__ << __LINE__; continue; }
141#define ENUM_NAME(o, e, v) (o::staticMetaObject.enumerator(o::staticMetaObject.indexOfEnumerator(#e)).valueToKey((v)))
154#define logDebug0(s) if (UMLApp::app()->logToConsole() || Tracer::instance()->isEnabled(DBG_SRC)) \
155 UMLApp::app()->logDebug(QStringLiteral(s))
156#define logInfo0(s) UMLApp::app()->logInfo(QStringLiteral(s))
157#define logWarn0(s) UMLApp::app()->logWarn(QStringLiteral(s))
158#define logError0(s) UMLApp::app()->logError(QStringLiteral(s))
160#define logDebug1(s, a) if (UMLApp::app()->logToConsole() || Tracer::instance()->isEnabled(DBG_SRC)) \
161 do { QString fmt = QString(QStringLiteral(s)).arg(a); UMLApp::app()->logDebug(fmt); } while (0)
162#define logInfo1(s, a) do { QString fmt = QString(QStringLiteral(s)).arg(a); UMLApp::app()->logInfo(fmt); } while (0)
163#define logWarn1(s, a) do { QString fmt = QString(QStringLiteral(s)).arg(a); UMLApp::app()->logWarn(fmt); } while (0)
164#define logError1(s, a) do { QString fmt = QString(QStringLiteral(s)).arg(a); UMLApp::app()->logError(fmt); } while (0)
166#define logDebug2(s, a, b) if (UMLApp::app()->logToConsole() || Tracer::instance()->isEnabled(DBG_SRC)) \
167 do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b); UMLApp::app()->logDebug(fmt); } while (0)
168#define logInfo2(s, a, b) do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b); UMLApp::app()->logInfo(fmt); } while (0)
169#define logWarn2(s, a, b) do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b); UMLApp::app()->logWarn(fmt); } while (0)
170#define logError2(s, a, b) do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b); UMLApp::app()->logError(fmt); } while (0)
172#define logDebug3(s, a, b, c) if (UMLApp::app()->logToConsole() || Tracer::instance()->isEnabled(DBG_SRC)) \
173 do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c); UMLApp::app()->logDebug(fmt); } while (0)
174#define logInfo3(s, a, b, c) do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c); UMLApp::app()->logInfo(fmt); } while (0)
175#define logWarn3(s, a, b, c) do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c); UMLApp::app()->logWarn(fmt); } while (0)
176#define logError3(s, a, b, c) do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c); UMLApp::app()->logError(fmt); } while (0)
178#define logDebug4(s, a, b, c, d) if (UMLApp::app()->logToConsole() || Tracer::instance()->isEnabled(DBG_SRC)) \
179 do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c).arg(d); UMLApp::app()->logDebug(fmt); } while (0)
180#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)
181#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)
182#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)
184#define logDebug5(s, a, b, c, d, e) if (UMLApp::app()->logToConsole() || Tracer::instance()->isEnabled(DBG_SRC)) \
185 do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c).arg(d).arg(e); \
186 UMLApp::app()->logDebug(fmt); } while (0)
187#define logInfo5(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()->logInfo(fmt); } while (0)
189#define logWarn5(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()->logWarn(fmt); } while (0)
191#define logError5(s, a, b, c, d, e) do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c).arg(d).arg(e); \
192 UMLApp::app()->logError(fmt); } while (0)
194#define logDebug6(s, a, b, c, d, e, f) if (UMLApp::app()->logToConsole() || Tracer::instance()->isEnabled(DBG_SRC)) \
195 do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c).arg(d).arg(e).arg(f); UMLApp::app()->logDebug(fmt); } while (0)
MapEntry(const QString &_filePath, bool _state)
Definition debug_utils.h:93
QString filePath
Definition debug_utils.h:90
bool state
Definition debug_utils.h:91
MapEntry()
Definition debug_utils.h:92
void restoreParentCheckState(QTreeWidgetItem *parent)
Definition debug_utils.cpp:351
static bool s_logToConsole
Definition debug_utils.h:102
void disable(const QString &name)
Definition debug_utils.cpp:185
static Tracer * s_instance
Definition debug_utils.h:99
void disableAll()
Definition debug_utils.cpp:209
void enableAll()
Definition debug_utils.cpp:192
void slotParentItemClicked(QTreeWidgetItem *parent)
Definition debug_utils.cpp:382
QMap< QString, Qt::CheckState > StateMap
Definition debug_utils.h:97
void updateParentItemCheckBox(QTreeWidgetItem *parent)
Definition debug_utils.cpp:294
void enable(const QString &name)
Definition debug_utils.cpp:175
~Tracer()
Definition debug_utils.cpp:148
bool logToConsole()
Definition debug_utils.cpp:226
static Tracer * instance()
Definition debug_utils.cpp:109
void updateAllItemCheckBox()
Definition debug_utils.cpp:267
static StateMap * s_states
Definition debug_utils.h:101
Tracer(QWidget *parent=nullptr)
Definition debug_utils.cpp:135
void update(const QString &name)
Definition debug_utils.cpp:257
bool isEnabled(const QString &name) const
Definition debug_utils.cpp:157
static MapType * s_classes
Definition debug_utils.h:100
static void registerClass(const char *name, bool state=true, const char *filePath=nullptr)
Definition debug_utils.cpp:237
virtual void showEvent(QShowEvent *)
Definition debug_utils.cpp:312
void slotItemClicked(QTreeWidgetItem *item, int column)
Definition debug_utils.cpp:401
QMap< QString, MapEntry > MapType
Definition debug_utils.h:96
QString toString(const T &value)
Definition debug_utils.h:147