TreeFrogFramework  1.18
tdebug.h
Go to the documentation of this file.
1 #ifndef TDEBUG_H
2 #define TDEBUG_H
3 
4 #include <TGlobal>
5 #include <QString>
6 #include <QTextStream>
7 
8 namespace Tf
9 {
10  T_CORE_EXPORT void setupAppLoggers(); // internal use
11  T_CORE_EXPORT void releaseAppLoggers(); // internal use
12 }
13 
14 
16 {
17 public:
18  TDebug(int priority) : msgPriority(priority) {}
19  TDebug(const TDebug &other);
20  ~TDebug();
21  TDebug &operator=(const TDebug &other);
22 
23  inline TDebug fatal() const { return TDebug(Tf::FatalLevel); }
24  inline TDebug error() const { return TDebug(Tf::ErrorLevel); }
25  inline TDebug warn() const { return TDebug(Tf::WarnLevel); }
26  inline TDebug info() const { return TDebug(Tf::InfoLevel); }
27  inline TDebug debug() const { return TDebug(Tf::DebugLevel); }
28  inline TDebug trace() const { return TDebug(Tf::TraceLevel); }
29 
30  void fatal(const char *fmt, ...) const T_ATTRIBUTE_FORMAT(2,3);
31  void error(const char *fmt, ...) const T_ATTRIBUTE_FORMAT(2,3);
32  void warn(const char *fmt, ...) const T_ATTRIBUTE_FORMAT(2,3);
33  void info(const char *fmt, ...) const T_ATTRIBUTE_FORMAT(2,3);
34  void debug(const char *fmt, ...) const T_ATTRIBUTE_FORMAT(2,3);
35  void trace(const char *fmt, ...) const T_ATTRIBUTE_FORMAT(2,3);
36 
37  inline TDebug &operator<<(QChar t) { ts << t; return *this; }
38  inline TDebug &operator<<(bool t) { ts << (t ? "true" : "false"); return *this; }
39  inline TDebug &operator<<(char t) { ts << t; return *this; }
40  inline TDebug &operator<<(short t) { ts << t; return *this; }
41  inline TDebug &operator<<(unsigned short t) { ts << t; return *this; }
42  inline TDebug &operator<<(int t) { ts << t; return *this; }
43  inline TDebug &operator<<(unsigned int t) { ts << t; return *this; }
44  inline TDebug &operator<<(long t) { ts << t; return *this; }
45  inline TDebug &operator<<(unsigned long t) { ts << t; return *this; }
46  inline TDebug &operator<<(qint64 t) { ts << t; return *this; }
47  inline TDebug &operator<<(quint64 t) { ts << t; return *this; }
48  inline TDebug &operator<<(float t) { ts << t; return *this; }
49  inline TDebug &operator<<(double t) { ts << t; return *this; }
50  inline TDebug &operator<<(const char* t) { ts << t; return *this; }
51  inline TDebug &operator<<(const QString &t) { ts << t; return *this; }
52  inline TDebug &operator<<(const QStringRef &t) { ts << t.toString(); return *this; }
53  inline TDebug &operator<<(const QLatin1String &t) { ts << t; return *this; }
54  inline TDebug &operator<<(const QByteArray &t) { ts << t; return *this; }
55  inline TDebug &operator<<(const QVariant &t) { ts << t.toString(); return *this; }
56  inline TDebug &operator<<(const void *t) { ts << t; return *this; }
57  inline TDebug &operator<<(std::nullptr_t) { ts << "(nullptr)"; return *this; }
58 
59 private:
60  QString buffer;
61  QTextStream ts {&buffer, QIODevice::WriteOnly};
62  int msgPriority {0};
63 };
64 
65 #endif // TDEBUG_H
TDebug debug() const
Definition: tdebug.h:27
#define T_CORE_EXPORT
Definition: tglobal.h:81
Potentially harmful situations.
Definition: tfnamespace.h:223
#define T_ATTRIBUTE_FORMAT(A, B)
Definition: tglobal.h:95
TDebug & operator<<(const void *t)
Definition: tdebug.h:56
T_CORE_EXPORT void releaseAppLoggers()
Releases all the loggers.
Definition: tdebug.cpp:56
Finer-grained informational events than the DEBUG.
Definition: tfnamespace.h:226
Informational events that are most useful to debug the app.
Definition: tfnamespace.h:225
TDebug & operator<<(const QString &t)
Definition: tdebug.h:51
TDebug & operator<<(quint64 t)
Definition: tdebug.h:47
T_CORE_EXPORT void setupAppLoggers()
Sets up all the loggers set in the logger.ini.
Definition: tdebug.cpp:35
TDebug info() const
Definition: tdebug.h:26
TDebug(int priority)
Definition: tdebug.h:18
The Tf namespace contains miscellaneous identifiers used throughout the library of TreeFrog Framework...
Definition: tdebug.h:8
TDebug & operator<<(float t)
Definition: tdebug.h:48
TDebug trace() const
Definition: tdebug.h:28
TDebug error() const
Definition: tdebug.h:24
TDebug fatal() const
Definition: tdebug.h:23
TDebug warn() const
Definition: tdebug.h:25
TDebug & operator<<(unsigned long t)
Definition: tdebug.h:45
TDebug & operator<<(const QByteArray &t)
Definition: tdebug.h:54
TDebug & operator<<(std::nullptr_t)
Definition: tdebug.h:57
TDebug & operator<<(bool t)
Definition: tdebug.h:38
Error events that might still allow the app to continue running.
Definition: tfnamespace.h:222
TDebug & operator<<(const QStringRef &t)
Definition: tdebug.h:52
TDebug & operator<<(const QLatin1String &t)
Definition: tdebug.h:53
TDebug & operator<<(qint64 t)
Definition: tdebug.h:46
TDebug & operator<<(double t)
Definition: tdebug.h:49
The TDebug class provides a file output stream for debugging information.
Definition: tdebug.h:15
TDebug & operator<<(const QVariant &t)
Definition: tdebug.h:55
void void void void void void TDebug & operator<<(QChar t)
Definition: tdebug.h:37
Informational messages that highlight the progress of the app.
Definition: tfnamespace.h:224
TDebug & operator<<(int t)
Definition: tdebug.h:42
TDebug & operator<<(long t)
Definition: tdebug.h:44
TDebug & operator<<(unsigned int t)
Definition: tdebug.h:43
TDebug & operator<<(char t)
Definition: tdebug.h:39
TDebug & operator<<(const char *t)
Definition: tdebug.h:50
Severe error events that will presumably lead the app to abort.
Definition: tfnamespace.h:221
TDebug & operator<<(short t)
Definition: tdebug.h:40
TDebug & operator<<(unsigned short t)
Definition: tdebug.h:41