28 #ifndef APPDEBUGMESSAGEHANDLER_H 29 #define APPDEBUGMESSAGEHANDLER_H 35 #include <QRegularExpression> 36 #include <QReadWriteLock> 39 #ifndef APP_DBG_HANDLER_ENABLE 40 #define APP_DBG_HANDLER_ENABLE 1 44 #ifndef APP_DBG_HANDLER_DEFAULT_LEVEL 45 #define APP_DBG_HANDLER_DEFAULT_LEVEL 0 50 #ifndef APP_DBG_HANDLER_SHOW_SRC_PATH 51 #define APP_DBG_HANDLER_SHOW_SRC_PATH 0 56 #ifndef APP_DBG_HANDLER_SHOW_FUNCTION_DECL 57 #define APP_DBG_HANDLER_SHOW_FUNCTION_DECL 0 61 #ifndef APP_DBG_HANDLER_SHOW_TIMESTAMP 62 #define APP_DBG_HANDLER_SHOW_TIMESTAMP 0 67 #ifndef APP_DBG_HANDLER_TIMESTAMP_FORMAT 68 #define APP_DBG_HANDLER_TIMESTAMP_FORMAT "process" 73 #ifndef APP_DBG_HANDLER_SRC_PATH 74 #define APP_DBG_HANDLER_SRC_PATH ".*src" 78 #if (QT_VERSION < QT_VERSION_CHECK(5, 5, 0)) 79 #if defined(QT_NO_INFO_OUTPUT) 80 #define qInfo QT_NO_QDEBUG_MACRO 84 #define QtInfoMsg QtMsgType(4) 212 #if (QT_VERSION < QT_VERSION_CHECK(5, 4, 0)) 224 QtMessageHandler m_defaultHandler;
226 quint8 m_appDebugOutputLevel;
228 bool m_showSourcePath;
229 bool m_showFunctionDeclarations;
230 bool m_showTimestamp;
233 mutable QString m_defaultPattern;
235 #if (QT_VERSION < QT_VERSION_CHECK(5, 4, 0)) 247 #endif // APPDEBUGMESSAGEHANDLER_H
void setShowTimestamp(bool showTimestamp)
static AppDebugMessageHandler * instance()
Get the singleton instance of this object. The instance is created automatically if necessary.
void messageOutput(quint8 level, const QString &msg)
Notifies when a new log massage is available.
bool showTimestamp() const
void setTimestampFormat(const QString &timeFormat)
bool showFunctionDeclarations() const
void installAppMessageHandler()
This function must be called to initialize this custom message handler. E.g. AppDebugMessageHandler::...
static QHash< int, QString > & shortTypeNames()
Returns a reference to the mapping of QtMsgType enum values to abbreviated names.
QString defaultMessagePattern() const
Returns the default message pattern. This format will take into account any properties set previously...
void setSourceBasePath(const QString &path=QString())
Set the base path for source file name filter, everything after this is kept. The string could be lit...
void addOutputDevice(QIODevice *device)
Add a new I/O stream for receiving messages.
void g_appDebugMessageHandler(QtMsgType, const QMessageLogContext &, const QString &)
QString messagePattern() const
Returns the current message pattern in use. This will be either the one set specifically with setMess...
void setAppDebugOutputLevel(quint8 appDebugOutputLevel)
QString timestampFormat() const
void setShowSourcePath(bool showSourcePath)
void setMessagePattern(const QString &pattern=QString())
Specifies a debug message pattern to use instead of the default.
bool showSourcePath() const
void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
Handle a debug message. This is typically called by the installed global message handler callback ( g...
void setShowFunctionDeclarations(bool showFunctionDeclarations)
Custom debug/message handler class to work in conjunction with qDebug() family of functions.
void removeOutputDevice(QIODevice *device)
Remove a previously-added I/O stream.
quint8 appDebugOutputLevel() const