XX CMake Package
Loading...
Searching...
No Matches
XXQtMessageInterceptor.h
Go to the documentation of this file.
1#ifndef XXQtMessageInterceptorH
2#define XXQtMessageInterceptorH
3
4#include "XXLogExportDef.h"
5#include <QObject>
6
7#include <functional>
8
9#include <QColor>
10#include <QMap>
11
12namespace XX
13{
14 namespace QtMessage
15 {
18
19 struct XXLOG_DECLSPEC Interceptor : public QObject
20 {
21 Q_OBJECT
22
23 public:
24 template <typename HandlerClass>
25 static bool enable(HandlerClass* instance, void (HandlerClass::*hanlderFunction)(QtMsgType, const QMessageLogContext&, const QString&));
26
27 template <typename HandlerClass>
28 static void disable(HandlerClass* instance);
29
30 static QString symbol(const QtMsgType& type);
31
32 private:
33 Interceptor();
34 ~Interceptor();
35
36 private:
37 using Function = std::function<void(QtMsgType, const QMessageLogContext&, const QString&)>;
38 using TargetMap = QMap<void*, Function>;
39
40 private:
41 Q_INVOKABLE void outputInternal(QtMsgType type, const QMessageLogContext& context, const QString& msg);
42 static void output(QtMsgType type, const QMessageLogContext& context, const QString& msg);
43
44 private:
45 static Interceptor* me;
46 QtMessageHandler systemHandler;
47 TargetMap targetMap;
48 };
49 } // namespace QtMessage
50} // namespace XX
51
52#ifndef XXQtMessageInterceptorHPP
53#include "XXQtMessageInterceptor.hpp"
54#endif // NOT XXQtMessageInterceptorHPP
55
56#endif // NOT XXQtMessageInterceptorH
#define XXLOG_DECLSPEC
Definition XXLogExportDef.h:11
Definition XXQtMessageDocument.h:12
Definition XXPopulatedAbstract.h:11
static bool enable(HandlerClass *instance, void(HandlerClass::*hanlderFunction)(QtMsgType, const QMessageLogContext &, const QString &))
static void disable(HandlerClass *instance)
static QString symbol(const QtMsgType &type)