File indexing completed on 2024-05-12 15:56:57

0001 /*
0002  *  SPDX-FileCopyrightText: 2005 Boudewijn Rempt <boud@valdyas.org>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 #ifndef KIS_DEBUG_H_
0007 #define KIS_DEBUG_H_
0008 
0009 #include <QDebug>
0010 #include <QLoggingCategory>
0011 
0012 #include "kritaglobal_export.h"
0013 
0014 /**
0015  * To show debug output, start krita like:
0016  *
0017  * QT_LOGGING_RULES="*.*=false;krita.metadata.*=true;krita.file.*=true"
0018  *
0019  */
0020 
0021 extern const KRITAGLOBAL_EXPORT QLoggingCategory &_30009();
0022 extern const KRITAGLOBAL_EXPORT QLoggingCategory &_41000();
0023 extern const KRITAGLOBAL_EXPORT QLoggingCategory &_41001();
0024 extern const KRITAGLOBAL_EXPORT QLoggingCategory &_41002();
0025 extern const KRITAGLOBAL_EXPORT QLoggingCategory &_41003();
0026 extern const KRITAGLOBAL_EXPORT QLoggingCategory &_41004();
0027 extern const KRITAGLOBAL_EXPORT QLoggingCategory &_41005();
0028 extern const KRITAGLOBAL_EXPORT QLoggingCategory &_41006();
0029 extern const KRITAGLOBAL_EXPORT QLoggingCategory &_41007();
0030 extern const KRITAGLOBAL_EXPORT QLoggingCategory &_41008();
0031 extern const KRITAGLOBAL_EXPORT QLoggingCategory &_41009();
0032 extern const KRITAGLOBAL_EXPORT QLoggingCategory &_41010();
0033 extern const KRITAGLOBAL_EXPORT QLoggingCategory &_41011();
0034 extern const KRITAGLOBAL_EXPORT QLoggingCategory &_41012();
0035 extern const KRITAGLOBAL_EXPORT QLoggingCategory &_41013();
0036 extern const KRITAGLOBAL_EXPORT QLoggingCategory &_41014();
0037 extern const KRITAGLOBAL_EXPORT QLoggingCategory &_41015();
0038 extern const KRITAGLOBAL_EXPORT QLoggingCategory &_41016();
0039 extern const KRITAGLOBAL_EXPORT QLoggingCategory &_41017();
0040 extern const KRITAGLOBAL_EXPORT QLoggingCategory &_41018();
0041 
0042 #define dbgResources qCDebug(_30009)
0043 #define dbgKrita qCDebug(_41000)
0044 #define dbgImage qCDebug(_41001)
0045 #define dbgRegistry qCDebug(_41002)
0046 #define dbgTools qCDebug(_41003)
0047 #define dbgTiles qCDebug(_41004)
0048 #define dbgFilters qCDebug(_41005)
0049 #define dbgPlugins qCDebug(_41006)
0050 #define dbgUI qCDebug(_41007)
0051 #define dbgFile qCDebug(_41008)
0052 #define dbgMath qCDebug(_41009)
0053 #define dbgRender qCDebug(_41010)
0054 #define dbgScript qCDebug(_41011)
0055 #define dbgInput qCDebug(_41012)
0056 #define dbgAction qCDebug(_41013)
0057 #define dbgTablet qCDebug(_41014)
0058 #define dbgOpenGL qCDebug(_41015)
0059 #define dbgMetaData qCDebug(_41016)
0060 #define dbgAndroid qCDebug(_41017)
0061 #define dbgLocale qCDebug(_41018)
0062 
0063 #define infoResources qCInfo(_30009)
0064 #define infoKrita qCInfo(_41000)
0065 #define infoImage qCInfo(_41001)
0066 #define infoRegistry qCInfo(_41002)
0067 #define infoTools qCInfo(_41003)
0068 #define infoTiles qCInfo(_41004)
0069 #define infoFilters qCInfo(_41005)
0070 #define infoPlugins qCInfo(_41006)
0071 #define infoUI qCInfo(_41007)
0072 #define infoFile qCInfo(_41008)
0073 #define infoMath qCInfo(_41009)
0074 #define infoRender qCInfo(_41010)
0075 #define infoScript qCInfo(_41011)
0076 #define infoInput qCInfo(_41012)
0077 #define infoAction qCDebug(_41013)
0078 #define infoTablet qCDebug(_41014)
0079 #define infoOpenGL qCDebug(_41015)
0080 #define infoMetaData qCDebug(_41016)
0081 
0082 #define warnResources qCWarning(_30009)
0083 #define warnKrita qCWarning(_41000)
0084 #define warnImage qCWarning(_41001)
0085 #define warnRegistry qCWarning(_41002)
0086 #define warnTools qCWarning(_41003)
0087 #define warnTiles qCWarning(_41004)
0088 #define warnFilters qCWarning(_41005)
0089 #define warnPlugins qCWarning(_41006)
0090 #define warnUI qCWarning(_41007)
0091 #define warnFile qCWarning(_41008)
0092 #define warnMath qCWarning(_41009)
0093 #define warnRender qCWarning(_41010)
0094 #define warnScript qCWarning(_41011)
0095 #define warnInput qCWarning(_41012)
0096 #define warnAction qCDebug(_41013)
0097 #define warnTablet qCDebug(_41014)
0098 #define warnOpenGL qCDebug(_41015)
0099 #define warnMetaData qCDebug(_41016)
0100 
0101 #define errResources qCCritical(_30009)
0102 #define errKrita qCCritical(_41000)
0103 #define errImage qCCritical(_41001)
0104 #define errRegistry qCCritical(_41002)
0105 #define errTools qCCritical(_41003)
0106 #define errTiles qCCritical(_41004)
0107 #define errFilters qCCritical(_41005)
0108 #define errPlugins qCCritical(_41006)
0109 #define errUI qCCritical(_41007)
0110 #define errFile qCCritical(_41008)
0111 #define errMath qCCritical(_41009)
0112 #define errRender qCCritical(_41010)
0113 #define errScript qCCritical(_41011)
0114 #define errInput qCCritical(_41012)
0115 #define errAction qCDebug(_41013)
0116 #define errTablet qCDebug(_41014)
0117 #define errOpenGL qCDebug(_41015)
0118 #define errMetaData qCDebug(_41016)
0119 
0120 // Qt does not yet define qCFatal (TODO: this is an oversight, submit a patch upstream)
0121 /*
0122 #define fatalResources qCFatal(_30009)
0123 #define fatalKrita qCFatal(_41000)
0124 #define fatalImage qCFatal(_41001)
0125 #define fatalRegistry qCFatal(_41002)
0126 #define fatalTools qCFatal(_41003)
0127 #define fatalTiles qCFatal(_41004)
0128 #define fatalFilters qCFatal(_41005)
0129 #define fatalPlugins qCFatal(_41006)
0130 #define fatalUI qCFatal(_41007)
0131 #define fatalFile qCFatal(_41008)
0132 #define fatalMath qCFatal(_41009)
0133 #define fatalRender qCFatal(_41010)
0134 #define fatalScript qCFatal(_41011)
0135 #define fatalInput qCFatal(_41012)
0136 #define fatalAction qCDebug(_41013)
0137 */
0138 
0139 
0140 /**
0141  * Show a nicely formatted backtrace.
0142  */
0143 KRITAGLOBAL_EXPORT QString kisBacktrace();
0144 
0145 /**
0146  * Please pretty print my variable
0147  *
0148  * Use this macro to display in the output stream the name of a variable followed by its value.
0149  */
0150 #define ppVar( var ) #var << "=" << (var)
0151 
0152 #  ifndef QT_NO_DEBUG
0153 #    undef Q_ASSERT
0154 #    define Q_ASSERT(cond) if(!(cond)) { errKrita.noquote() << kisBacktrace(); qt_assert(#cond,__FILE__,__LINE__); } qt_noop()
0155 #  endif
0156 
0157 
0158 #ifdef __GNUC__
0159 KRITAGLOBAL_EXPORT QString __methodName(const char *prettyFunction);
0160 #define __METHOD_NAME__ __methodName(__PRETTY_FUNCTION__)
0161 #else
0162 #define __METHOD_NAME__ "<unknown>:<unknown>"
0163 #endif
0164 
0165 #define PREPEND_METHOD(msg) QString("%1: %2").arg(__METHOD_NAME__).arg(msg)
0166 
0167 #ifdef __GNUC__
0168 #define ENTER_FUNCTION() qDebug() << "Entering" << __METHOD_NAME__
0169 #define LEAVE_FUNCTION() qDebug() << "Leaving " << __METHOD_NAME__
0170 #else
0171 #define ENTER_FUNCTION() qDebug() << "Entering" << "<unknown>"
0172 #define LEAVE_FUNCTION() qDebug() << "Leaving " << "<unknown>"
0173 #endif
0174 
0175 #include "kis_assert.h"
0176 
0177 #endif