]> Shamusworld >> Repos - architektonas/blob - src/base/debug.h
Removed unnecessary RS_ prefix from classes and whatnot.
[architektonas] / src / base / debug.h
1 #ifndef __DEBUG_H__
2 #define __DEBUG_H__
3
4 #ifdef hpux
5 #include <sys/_size_t.h>
6 #endif
7
8 #include <iostream>
9 #include <stdio.h>
10 #include <QtCore>
11
12 #define DEBUG Debug::instance()
13
14 /**
15  * Debugging facilities.
16  *
17  * @author James Hammons
18  * @author Andrew Mustun
19  */
20 class Debug
21 {
22         public:
23                 /**
24                  * Enum for debug levels. Only messages of the current
25                  * or a higher level are printed.
26                  * <ul>
27                  *  <li>D_NOTHING:  nothing
28                  *  <li>D_CRITICAL: critical messages
29                  *  <li>D_ERROR:    errors
30                  *  <li>D_WARNING:  warnings
31                  *  <li>D_NOTICE:   notes
32                  *  <li>D_INFORMATIONAL: infos
33                  *  <li>D_DEBUGGING: very verbose
34                  * </ul>
35                  */
36                 enum DebugLevel { D_NOTHING,
37                         D_CRITICAL,
38                         D_ERROR,
39                         D_WARNING,
40                         D_NOTICE,
41                         D_INFORMATIONAL,
42                         D_DEBUGGING };
43
44         private:
45                 Debug();
46
47         public:
48                 static Debug * instance();
49                 static void deleteInstance();
50
51                 void setLevel(DebugLevel level);
52                 DebugLevel getLevel();
53                 void print(DebugLevel level, const char * format ...);
54                 void print(const char * format ...);
55                 void printUnicode(const QString & text);
56                 void timestamp();
57                 void setStream(FILE * s);
58
59         private:
60                 static Debug * uniqueInstance;
61
62                 DebugLevel debugLevel;
63                 FILE * stream;
64 };
65
66 #endif  // __DEBUG_H__