]> Shamusworld >> Repos - architektonas/blob - src/base/rs_debug.h
Fixed thumbnail rendering in LibraryWidget and DXF detection.
[architektonas] / src / base / rs_debug.h
1 #ifndef RS_DEBUG_H
2 #define RS_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 RS_DEBUG RS_Debug::instance()
13
14 /**
15  * Debugging facilities.
16  *
17  * @author Andrew Mustun
18  */
19 class RS_Debug
20 {
21         public:
22                 /**
23                  * Enum for debug levels. Only messages of the current
24                  * or a higher level are printed.
25                  * <ul>
26                  *  <li>D_NOTHING:  nothing
27                  *  <li>D_CRITICAL: critical messages
28                  *  <li>D_ERROR:    errors
29                  *  <li>D_WARNING:  warnings
30                  *  <li>D_NOTICE:   notes
31                  *  <li>D_INFORMATIONAL: infos
32                  *  <li>D_DEBUGGING: very verbose
33                  * </ul>
34                  */
35                 enum RS_DebugLevel { D_NOTHING,
36                                                         D_CRITICAL,
37                                                         D_ERROR,
38                                                         D_WARNING,
39                                                         D_NOTICE,
40                                                         D_INFORMATIONAL,
41                                                         D_DEBUGGING };
42
43         private:
44                 RS_Debug();
45
46         public:
47                 static RS_Debug * instance();
48                 static void deleteInstance();
49
50                 void setLevel(RS_DebugLevel level);
51                 RS_DebugLevel getLevel();
52                 void print(RS_DebugLevel level, const char * format ...);
53                 void print(const char * format ...);
54                 void printUnicode(const QString & text);
55                 void timestamp();
56                 void setStream(FILE * s);
57
58         private:
59                 static RS_Debug * uniqueInstance;
60
61                 RS_DebugLevel debugLevel;
62                 FILE * stream;
63 };
64
65 #endif