1 | /* |
---|
2 | orxonox - the future of 3D-vertical-scrollers |
---|
3 | |
---|
4 | Copyright (C) 2004 orx |
---|
5 | |
---|
6 | This program is free software; you can redistribute it and/or modify |
---|
7 | it under the terms of the GNU General Public License as published by |
---|
8 | the Free Software Foundation; either version 2, or (at your option) |
---|
9 | any later version. |
---|
10 | |
---|
11 | ### File Specific: |
---|
12 | main-programmer: Benjamin Grauer |
---|
13 | co-programmer: ... |
---|
14 | */ |
---|
15 | |
---|
16 | /*! |
---|
17 | \file debug.h |
---|
18 | \brief Handles output to console for different Verbose-Modes. |
---|
19 | */ |
---|
20 | |
---|
21 | #ifndef _DEBUG_H |
---|
22 | #define _DEBUG_H |
---|
23 | |
---|
24 | #if HAVE_CONFIG_H |
---|
25 | #include <config.h> |
---|
26 | #endif |
---|
27 | |
---|
28 | #include <stdio.h> |
---|
29 | |
---|
30 | // DEFINE ERROR MODES |
---|
31 | #define NO 0 |
---|
32 | #define ERR 1 |
---|
33 | #define WARN 2 |
---|
34 | #define INFO 3 |
---|
35 | #define DEBUGING 4 |
---|
36 | #define vDEBUGING 5 |
---|
37 | |
---|
38 | #ifndef DEBUG_SPECIAL_MODULE |
---|
39 | extern int verbose; |
---|
40 | #else |
---|
41 | // DEFINE MODULES \\ |
---|
42 | #define DEBUG_MODULE_ORXONOX 0 |
---|
43 | #define DEBUG_MODULE_WORLD 0 |
---|
44 | #define DEBUG_MODULE_PNODE 0 |
---|
45 | #define DEBUG_MODULE_WORLD_ENTITY 0 |
---|
46 | #define DEBUG_MODULE_COMMAND_NODE 0 |
---|
47 | |
---|
48 | #define DEBUG_MODULE_IMPORTER 0 |
---|
49 | #define DEBUG_MODULE_TRACK_MANAGER 0 |
---|
50 | #define DEBUG_MODULE_LIGHT 0 |
---|
51 | #define DEBUG_MODULE_PLAYER 0 |
---|
52 | #define DEBUG_MODULE_MATH 0 |
---|
53 | |
---|
54 | #define DEBUG_MODULE_NULL_PARENT 0 |
---|
55 | |
---|
56 | #define verbose DEBUG_SPECIAL_MODULE |
---|
57 | |
---|
58 | #endif |
---|
59 | /////////////////////////////////////////////////// |
---|
60 | /// PRINTF: prints with filename and linenumber /// |
---|
61 | /////////////////////////////////////////////////// |
---|
62 | |
---|
63 | #ifdef DEBUG |
---|
64 | |
---|
65 | #define PRINTF(x) \ |
---|
66 | PRINTF ## x |
---|
67 | |
---|
68 | #if DEBUG >= ERR |
---|
69 | #define PRINTF1 \ |
---|
70 | if (verbose >= ERR) \ |
---|
71 | printf("ERROR::%s:%d:", __FILE__, __LINE__) && printf |
---|
72 | #else |
---|
73 | #define PRINTF1 if (NO) |
---|
74 | #endif |
---|
75 | |
---|
76 | #if DEBUG >= WARN |
---|
77 | #define PRINTF2 \ |
---|
78 | if (verbose >= WARN) \ |
---|
79 | printf("WARNING::%s:%d:", __FILE__, __LINE__) && printf |
---|
80 | |
---|
81 | #else |
---|
82 | #define PRINTF2 if (NO) |
---|
83 | #endif |
---|
84 | |
---|
85 | #if DEBUG >= INFO |
---|
86 | #define PRINTF3 \ |
---|
87 | if (verbose >= INFO) \ |
---|
88 | printf("INFO::%s:%d:", __FILE__, __LINE__) && printf |
---|
89 | #else |
---|
90 | #define PRINTF3 if (NO) |
---|
91 | #endif |
---|
92 | |
---|
93 | #if DEBUG >= DEBUGING |
---|
94 | #define PRINTF4 \ |
---|
95 | if (verbose >= DEBUGING) \ |
---|
96 | printf("DEBUG::%s:%d:", __FILE__, __LINE__) && printf |
---|
97 | #else |
---|
98 | #define PRINTF4 if (NO) |
---|
99 | #endif |
---|
100 | |
---|
101 | #if DEBUG >= vDEBUGING |
---|
102 | #define PRINTF5 \ |
---|
103 | if (verbose >= vDEBUGING) \ |
---|
104 | printf("VERYDEBUG::%s:%d:", __FILE__, __LINE__) && printf |
---|
105 | #else |
---|
106 | #define PRINTF5 if (NO) |
---|
107 | #endif |
---|
108 | |
---|
109 | #else |
---|
110 | #define PRINTF(x) if (NO) |
---|
111 | #endif |
---|
112 | |
---|
113 | #define PRINTF0 \ |
---|
114 | printf("%s:%d::", __FILE__, __LINE__) && printf |
---|
115 | |
---|
116 | |
---|
117 | /////////////////////////////////////////////////// |
---|
118 | /// PRINT: just prints output as is /// |
---|
119 | /////////////////////////////////////////////////// |
---|
120 | #ifdef DEBUG |
---|
121 | #define PRINT(x) \ |
---|
122 | PRINT ## x |
---|
123 | |
---|
124 | #if DEBUG >= ERR |
---|
125 | #define PRINT1 \ |
---|
126 | if (verbose >= ERR) \ |
---|
127 | printf |
---|
128 | #else |
---|
129 | #define PRINT1 if (NO) |
---|
130 | #endif |
---|
131 | |
---|
132 | #if DEBUG >= WARN |
---|
133 | #define PRINT2 \ |
---|
134 | if (verbose >= WARN) \ |
---|
135 | printf |
---|
136 | |
---|
137 | #else |
---|
138 | #define PRINT2 if (NO) |
---|
139 | #endif |
---|
140 | |
---|
141 | #if DEBUG >= INFO |
---|
142 | #define PRINT3 \ |
---|
143 | if (verbose >= INFO) \ |
---|
144 | printf |
---|
145 | #else |
---|
146 | #define PRINT3 if (NO) |
---|
147 | #endif |
---|
148 | |
---|
149 | #if DEBUG >= DEBUGING |
---|
150 | #define PRINT4 \ |
---|
151 | if (verbose >= DEBUGING) \ |
---|
152 | printf |
---|
153 | #else |
---|
154 | #define PRINT4 if (NO) |
---|
155 | #endif |
---|
156 | |
---|
157 | #if DEBUG >= vDEBUGING |
---|
158 | #define PRINT5 \ |
---|
159 | if (verbose >= vDEBUGING) \ |
---|
160 | printf("VERYDEBUG::%s:%d:", __FILE__, __LINE__) && printf |
---|
161 | #else |
---|
162 | #define PRINT5 if (NO) |
---|
163 | #endif |
---|
164 | |
---|
165 | |
---|
166 | #else |
---|
167 | #define PRINT(x) if (NO) |
---|
168 | #endif |
---|
169 | |
---|
170 | #define PRINT0 \ |
---|
171 | printf |
---|
172 | |
---|
173 | /////////////////////////////////////////////////// |
---|
174 | /// COUT: simple cout print with verbose-check /// |
---|
175 | /////////////////////////////////////////////////// |
---|
176 | #ifdef DEBUG |
---|
177 | #define COUT(x) \ |
---|
178 | COUT ## x |
---|
179 | |
---|
180 | #if DEBUG >= 1 |
---|
181 | #define COUT1 \ |
---|
182 | if (verbose >= 1 ) \ |
---|
183 | cout |
---|
184 | #else |
---|
185 | #define COUT1 if (NO) cout |
---|
186 | #endif |
---|
187 | |
---|
188 | #if DEBUG >= 2 |
---|
189 | #define COUT2 \ |
---|
190 | if (verbose >= 2 ) \ |
---|
191 | cout |
---|
192 | |
---|
193 | #else |
---|
194 | #define COUT2 if (NO) cout |
---|
195 | #endif |
---|
196 | |
---|
197 | #if DEBUG >= 3 |
---|
198 | #define COUT3 \ |
---|
199 | if (verbose >= 3 ) \ |
---|
200 | cout |
---|
201 | #else |
---|
202 | #define COUT3 if (NO) cout |
---|
203 | #endif |
---|
204 | |
---|
205 | #if DEBUG >= 4 |
---|
206 | #define COUT4 \ |
---|
207 | if (verbose >= 4 ) \ |
---|
208 | cout |
---|
209 | #else |
---|
210 | #define COUT4 if (NO) cout |
---|
211 | #endif |
---|
212 | |
---|
213 | |
---|
214 | #else |
---|
215 | #define COUT(x) if (NO) cout |
---|
216 | #endif |
---|
217 | |
---|
218 | #define COUT0 \ |
---|
219 | cout |
---|
220 | |
---|
221 | #endif /* _DEBUG_H */ |
---|