19 #include <QLoggingCategory> 20 Q_DECLARE_LOGGING_CATEGORY(UMBRELLO)
22 #include <QTreeWidget> 24 namespace Settings {
class OptionState; }
67 bool isEnabled(
const QString& name)
const;
68 void enable(
const QString& name);
69 void disable(
const QString& name);
76 static void registerClass(
const char * name,
bool state=
true,
const char *filePath =
nullptr);
80 void update(
const QString &name);
107 explicit Tracer(QWidget *parent =
nullptr);
111 #define uDebug() qCDebug(UMBRELLO) 112 #define uError() qCCritical(UMBRELLO) 113 #define uWarning() qCWarning(UMBRELLO) 116 #define DBG_SRC QString::fromLatin1(metaObject()->className()) 118 #define DEBUG_SHOW_FILTER() Tracer::instance()->show() 119 #define DEBUG_N(latin1str) if (Tracer::instance()->logToConsole() || Tracer::instance()->isEnabled(latin1str)) uDebug() 120 #define DEBUG() DEBUG_N(DBG_SRC) 121 #define IS_DEBUG_ENABLED() Tracer::instance()->isEnabled(DBG_SRC) 122 #define DEBUG_REGISTER(src) \ 123 class src##Tracer { \ 125 src##Tracer() { Tracer::registerClass(#src, true, __FILE__); } \ 127 static src##Tracer src##TracerGlobal; 128 #define DEBUG_REGISTER_DISABLED(src) \ 129 class src##Tracer { \ 131 src##Tracer() { Tracer::registerClass(#src, false, __FILE__); } \ 133 static src##Tracer src##TracerGlobal; 135 #define uIgnoreZeroPointer(a) if (!a) { uDebug() << "zero pointer detected" << __FILE__ << __LINE__; continue; } 144 #define ENUM_NAME(o, e, v) (o::staticMetaObject.enumerator(o::staticMetaObject.indexOfEnumerator(#e)).valueToKey((v))) 146 template <
typename T>
149 template <
typename T>
157 #define logDebug0(s) if (UMLApp::app()->logToConsole() || Tracer::instance()->isEnabled(DBG_SRC)) \ 158 UMLApp::app()->logDebug(QStringLiteral(s)) 159 #define logInfo0(s) UMLApp::app()->logInfo(QStringLiteral(s)) 160 #define logWarn0(s) UMLApp::app()->logWarn(QStringLiteral(s)) 161 #define logError0(s) UMLApp::app()->logError(QStringLiteral(s)) 163 #define logDebug1(s, a) if (UMLApp::app()->logToConsole() || Tracer::instance()->isEnabled(DBG_SRC)) \ 164 do { QString fmt = QString(QStringLiteral(s)).arg(a); UMLApp::app()->logDebug(fmt); } while (0) 165 #define logInfo1(s, a) do { QString fmt = QString(QStringLiteral(s)).arg(a); UMLApp::app()->logInfo(fmt); } while (0) 166 #define logWarn1(s, a) do { QString fmt = QString(QStringLiteral(s)).arg(a); UMLApp::app()->logWarn(fmt); } while (0) 167 #define logError1(s, a) do { QString fmt = QString(QStringLiteral(s)).arg(a); UMLApp::app()->logError(fmt); } while (0) 169 #define logDebug2(s, a, b) if (UMLApp::app()->logToConsole() || Tracer::instance()->isEnabled(DBG_SRC)) \ 170 do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b); UMLApp::app()->logDebug(fmt); } while (0) 171 #define logInfo2(s, a, b) do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b); UMLApp::app()->logInfo(fmt); } while (0) 172 #define logWarn2(s, a, b) do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b); UMLApp::app()->logWarn(fmt); } while (0) 173 #define logError2(s, a, b) do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b); UMLApp::app()->logError(fmt); } while (0) 175 #define logDebug3(s, a, b, c) if (UMLApp::app()->logToConsole() || Tracer::instance()->isEnabled(DBG_SRC)) \ 176 do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c); UMLApp::app()->logDebug(fmt); } while (0) 177 #define logInfo3(s, a, b, c) do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c); UMLApp::app()->logInfo(fmt); } while (0) 178 #define logWarn3(s, a, b, c) do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c); UMLApp::app()->logWarn(fmt); } while (0) 179 #define logError3(s, a, b, c) do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c); UMLApp::app()->logError(fmt); } while (0) 181 #define logDebug4(s, a, b, c, d) if (UMLApp::app()->logToConsole() || Tracer::instance()->isEnabled(DBG_SRC)) \ 182 do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c).arg(d); UMLApp::app()->logDebug(fmt); } while (0) 183 #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) 184 #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) 185 #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) 187 #define logDebug5(s, a, b, c, d, e) if (UMLApp::app()->logToConsole() || Tracer::instance()->isEnabled(DBG_SRC)) \ 188 do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c).arg(d).arg(e); \ 189 UMLApp::app()->logDebug(fmt); } while (0) 190 #define logInfo5(s, a, b, c, d, e) do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c).arg(d).arg(e); \ 191 UMLApp::app()->logInfo(fmt); } while (0) 192 #define logWarn5(s, a, b, c, d, e) do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c).arg(d).arg(e); \ 193 UMLApp::app()->logWarn(fmt); } while (0) 194 #define logError5(s, a, b, c, d, e) do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c).arg(d).arg(e); \ 195 UMLApp::app()->logError(fmt); } while (0) 197 #define logDebug6(s, a, b, c, d, e, f) if (UMLApp::app()->logToConsole() || Tracer::instance()->isEnabled(DBG_SRC)) \ 198 do { QString fmt = QString(QStringLiteral(s)).arg(a).arg(b).arg(c).arg(d).arg(e).arg(f); UMLApp::app()->logDebug(fmt); } while (0) static StateMap * s_states
Definition: debug_utils.h:104
virtual void showEvent(QShowEvent *)
Definition: debug_utils.cpp:329
Definition: optionstate.h:314
void updateParentItemCheckBox(QTreeWidgetItem *parent)
Definition: debug_utils.cpp:311
void slotItemClicked(QTreeWidgetItem *item, int column)
Definition: debug_utils.cpp:419
static bool s_logToConsole
Definition: debug_utils.h:105
bool state
Definition: debug_utils.h:94
QString filePath
Definition: debug_utils.h:93
QMap< QString, Qt::CheckState > StateMap
Definition: debug_utils.h:100
~Tracer()
Definition: debug_utils.cpp:152
void update(const QString &name)
Definition: debug_utils.cpp:274
QString toString(const T &value)
Definition: debug_utils.h:150
void enableAll()
Definition: debug_utils.cpp:209
static MapType * s_classes
Definition: debug_utils.h:103
static Tracer * instance()
Definition: debug_utils.cpp:113
MapEntry(const QString &_filePath, bool _state)
Definition: debug_utils.h:96
Definition: debug_utils.h:91
void disable(const QString &name)
Definition: debug_utils.cpp:202
Definition: codeviewerstate.cpp:10
bool isEnabled(const QString &name) const
Definition: debug_utils.cpp:171
static void registerClass(const char *name, bool state=true, const char *filePath=nullptr)
Definition: debug_utils.cpp:254
void slotParentItemClicked(QTreeWidgetItem *parent)
Definition: debug_utils.cpp:400
static void onSettingsChanged(const Settings::OptionState &state)
Definition: debug_utils.cpp:159
MapEntry()
Definition: debug_utils.h:95
QMap< QString, MapEntry > MapType
Definition: debug_utils.h:99
void updateAllItemCheckBox()
Definition: debug_utils.cpp:284
void enable(const QString &name)
Definition: debug_utils.cpp:192
bool logToConsole()
Definition: debug_utils.cpp:243
static Tracer * s_instance
Definition: debug_utils.h:102
Tracer(QWidget *parent=nullptr)
Definition: debug_utils.cpp:139
void restoreParentCheckState(QTreeWidgetItem *parent)
Definition: debug_utils.cpp:369
void disableAll()
Definition: debug_utils.cpp:226
The singleton class for switching on or off debug messages.
Definition: debug_utils.h:59