1 | /* |
---|
2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
3 | * |
---|
4 | * |
---|
5 | * License notice: |
---|
6 | * |
---|
7 | * This program is free software; you can redistribute it and/or |
---|
8 | * modify it under the terms of the GNU General Public License |
---|
9 | * as published by the Free Software Foundation; either version 2 |
---|
10 | * of the License, or (at your option) any later version. |
---|
11 | * |
---|
12 | * This program is distributed in the hope that it will be useful, |
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | * GNU General Public License for more details. |
---|
16 | * |
---|
17 | * You should have received a copy of the GNU General Public License |
---|
18 | * along with this program; if not, write to the Free Software |
---|
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
20 | * |
---|
21 | * Author: |
---|
22 | * Benjamin Grauer |
---|
23 | * Co-authors: |
---|
24 | * Fabian 'x3n' Landau |
---|
25 | * |
---|
26 | */ |
---|
27 | |
---|
28 | /*! |
---|
29 | * @file Debug.h |
---|
30 | * @brief Handles the output for different verbose-modes. |
---|
31 | * |
---|
32 | * There are two modes: HARD and SOFT. HARD is precessed during compiletime, while SOFT is for runtime. |
---|
33 | */ |
---|
34 | |
---|
35 | #ifndef _Debug_H__ |
---|
36 | #define _Debug_H__ |
---|
37 | |
---|
38 | #include <stdio.h> |
---|
39 | |
---|
40 | #include "CorePrereqs.h" |
---|
41 | |
---|
42 | #include "OutputHandler.h" |
---|
43 | |
---|
44 | extern "C" _CoreExport int getSoftDebugLevel(); |
---|
45 | |
---|
46 | // DEFINE ERROR MODES |
---|
47 | #define ORX_NONE 0 |
---|
48 | #define ORX_ERROR 1 |
---|
49 | #define ORX_WARNING 2 |
---|
50 | #define ORX_INFO 3 |
---|
51 | #define ORX_DEBUG 4 |
---|
52 | #define ORX_vDEBUG 5 |
---|
53 | |
---|
54 | //definitions |
---|
55 | #define ORX_PRINT_DEBUG_OUTPUT 1 // <-- fix that! should be a configurable setting |
---|
56 | |
---|
57 | #define ORX_HARD_DEBUG_LEVEL ORX_DEBUG |
---|
58 | //#define ORX_SOFT_DEBUG_LEVEL ORX_WARNING // <-- fix that! should be a configurable setting |
---|
59 | |
---|
60 | /////////////////////////////////////////////////// |
---|
61 | /// PRINTF: prints with filename and linenumber /// |
---|
62 | /////////////////////////////////////////////////// |
---|
63 | #define PRINTFORX_NONE PRINTF0 |
---|
64 | #define PRINTFORX_ERROR PRINTF1 |
---|
65 | #define PRINTFORX_WARNING PRINTF2 |
---|
66 | #define PRINTFORX_INFO PRINTF3 |
---|
67 | #define PRINTFORX_DEBUG PRINTF4 |
---|
68 | #define PRINTFORX_vDEBUG PRINTF5 |
---|
69 | |
---|
70 | #define PRINT_EXEC printf |
---|
71 | #define COUT_EXEC(x) \ |
---|
72 | orxonox::OutputHandler::getOutStream().setOutputLevel(x) |
---|
73 | |
---|
74 | #ifndef PRINTF |
---|
75 | #if ORX_PRINT_DEBUG_OUTPUT |
---|
76 | |
---|
77 | #define PRINTF(x) \ |
---|
78 | PRINTF ## x |
---|
79 | |
---|
80 | #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR |
---|
81 | #define PRINTF1 \ |
---|
82 | if (getSoftDebugLevel() >= ORX_ERROR) \ |
---|
83 | printf("Error (in %s, line %d): ", __FILE__, __LINE__), PRINT_EXEC |
---|
84 | #else |
---|
85 | #define PRINTF1 if (ORX_NONE) PRINT_EXEC |
---|
86 | #endif |
---|
87 | |
---|
88 | #if ORX_HARD_DEBUG_LEVEL >= ORX_WARNING |
---|
89 | #define PRINTF2 \ |
---|
90 | if (getSoftDebugLevel() >= ORX_WARNING) \ |
---|
91 | printf("Warning (in %s, line %d): ", __FILE__, __LINE__), PRINT_EXEC |
---|
92 | #else |
---|
93 | #define PRINTF2 if (ORX_NONE) PRINT_EXEC |
---|
94 | #endif |
---|
95 | |
---|
96 | #if ORX_HARD_DEBUG_LEVEL >= ORX_INFO |
---|
97 | #define PRINTF3 \ |
---|
98 | if (getSoftDebugLevel() >= ORX_INFO) \ |
---|
99 | printf("Info (in %s, line %d): ", __FILE__, __LINE__), PRINT_EXEC |
---|
100 | #else |
---|
101 | #define PRINTF3 if (ORX_NONE) PRINT_EXEC |
---|
102 | #endif |
---|
103 | |
---|
104 | #if ORX_HARD_DEBUG_LEVEL >= ORX_DEBUG |
---|
105 | #define PRINTF4 \ |
---|
106 | if (getSoftDebugLevel() >= ORX_DEBUG) \ |
---|
107 | printf("Debug (in %s, line %d): ", __FILE__, __LINE__), PRINT_EXEC |
---|
108 | #else |
---|
109 | #define PRINTF4 if (ORX_NONE) PRINT_EXEC |
---|
110 | #endif |
---|
111 | |
---|
112 | #if ORX_HARD_DEBUG_LEVEL >= ORX_vDEBUG |
---|
113 | #define PRINTF5 \ |
---|
114 | if (getSoftDebugLevel() >= ORX_vDEBUG) \ |
---|
115 | printf("vDebug (in %s, line %d): ", __FILE__, __LINE__), PRINT_EXEC |
---|
116 | #else |
---|
117 | #define PRINTF5 if (ORX_NONE) PRINT_EXEC |
---|
118 | #endif |
---|
119 | |
---|
120 | #else /* if ORX_PRINT_DEBUG_OUTPUT */ |
---|
121 | #define PRINTF(x) if (ORX_NONE) PRINT_EXEC |
---|
122 | #endif /* if ORX_PRINT_DEBUG_OUTPUT */ |
---|
123 | |
---|
124 | #define PRINTF0 \ |
---|
125 | PRINT_EXEC |
---|
126 | #endif /* ifndef PRINTF */ |
---|
127 | |
---|
128 | /////////////////////////////////////////////////// |
---|
129 | /// PRINT: just prints output as is /// |
---|
130 | /////////////////////////////////////////////////// |
---|
131 | #define PRINTORX_NONE PRINT0 |
---|
132 | #define PRINTORX_ERROR PRINT1 |
---|
133 | #define PRINTORX_WARNING PRINT2 |
---|
134 | #define PRINTORX_INFO PRINT3 |
---|
135 | #define PRINTORX_DEBUG PRINT4 |
---|
136 | #define PRINTORX_vDEBUG PRINT5 |
---|
137 | |
---|
138 | #ifndef PRINT |
---|
139 | #if ORX_PRINT_DEBUG_OUTPUT |
---|
140 | #define PRINT(x) \ |
---|
141 | PRINT ## x |
---|
142 | |
---|
143 | #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR |
---|
144 | #define PRINT1 \ |
---|
145 | if (getSoftDebugLevel() >= ORX_ERROR) \ |
---|
146 | PRINT_EXEC |
---|
147 | #else |
---|
148 | #define PRINT1 if (ORX_NONE) PRINT_EXEC |
---|
149 | #endif |
---|
150 | |
---|
151 | #if ORX_HARD_DEBUG_LEVEL >= ORX_WARNING |
---|
152 | #define PRINT2 \ |
---|
153 | if (getSoftDebugLevel() >= ORX_WARNING) \ |
---|
154 | PRINT_EXEC |
---|
155 | #else |
---|
156 | #define PRINT2 if (ORX_NONE) PRINT_EXEC |
---|
157 | #endif |
---|
158 | |
---|
159 | #if ORX_HARD_DEBUG_LEVEL >= ORX_INFO |
---|
160 | #define PRINT3 \ |
---|
161 | if (getSoftDebugLevel() >= ORX_INFO) \ |
---|
162 | PRINT_EXEC |
---|
163 | #else |
---|
164 | #define PRINT3 if (ORX_NONE) PRINT_EXEC |
---|
165 | #endif |
---|
166 | |
---|
167 | #if ORX_HARD_DEBUG_LEVEL >= ORX_DEBUG |
---|
168 | #define PRINT4 \ |
---|
169 | if (getSoftDebugLevel() >= ORX_DEBUG) \ |
---|
170 | PRINT_EXEC |
---|
171 | #else |
---|
172 | #define PRINT4 if (ORX_NONE) PRINT_EXEC |
---|
173 | #endif |
---|
174 | |
---|
175 | #if ORX_HARD_DEBUG_LEVEL >= ORX_vDEBUG |
---|
176 | #define PRINT5 \ |
---|
177 | if (getSoftDebugLevel() >= ORX_vDEBUG) \ |
---|
178 | PRINT_EXEC |
---|
179 | #else |
---|
180 | #define PRINT5 if (ORX_NONE) PRINT_EXEC |
---|
181 | #endif |
---|
182 | |
---|
183 | #else /* if ORX_PRINT_DEBUG_OUTPUT */ |
---|
184 | #define PRINT(x) if (ORX_NONE) PRINT_EXEC |
---|
185 | #endif /* if ORX_PRINT_DEBUG_OUTPUT */ |
---|
186 | |
---|
187 | #define PRINT0 \ |
---|
188 | PRINT_EXEC |
---|
189 | #endif /* ifndef PRINT */ |
---|
190 | |
---|
191 | |
---|
192 | //////////////////////////////////////////////////////// |
---|
193 | /// COUT: just prints output as is with std::cout /// |
---|
194 | //////////////////////////////////////////////////////// |
---|
195 | #define COUTORX_NONE COUT0 |
---|
196 | #define COUTORX_ERROR COUT1 |
---|
197 | #define COUTORX_WARNING COUT2 |
---|
198 | #define COUTORX_INFO COUT3 |
---|
199 | #define COUTORX_DEBUG COUT4 |
---|
200 | #define COUTORX_vDEBUG COUT5 |
---|
201 | |
---|
202 | #ifndef COUT |
---|
203 | #if ORX_PRINT_DEBUG_OUTPUT |
---|
204 | #define COUT(x) \ |
---|
205 | COUT ## x |
---|
206 | |
---|
207 | #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR |
---|
208 | #define COUT1 \ |
---|
209 | if (getSoftDebugLevel() >= ORX_ERROR) \ |
---|
210 | COUT_EXEC(1) |
---|
211 | #else |
---|
212 | #define COUT1 if (ORX_NONE)\ |
---|
213 | COUT_EXEC(1) |
---|
214 | #endif |
---|
215 | |
---|
216 | #if ORX_HARD_DEBUG_LEVEL >= ORX_WARNING |
---|
217 | #define COUT2 \ |
---|
218 | if (getSoftDebugLevel() >= ORX_WARNING) \ |
---|
219 | COUT_EXEC(2) |
---|
220 | #else |
---|
221 | #define COUT2 if (ORX_NONE) \ |
---|
222 | COUT_EXEC(2) |
---|
223 | #endif |
---|
224 | |
---|
225 | #if ORX_HARD_DEBUG_LEVEL >= ORX_INFO |
---|
226 | #define COUT3 \ |
---|
227 | if (getSoftDebugLevel() >= ORX_INFO) \ |
---|
228 | COUT_EXEC(3) |
---|
229 | #else |
---|
230 | #define COUT3 if (ORX_NONE) \ |
---|
231 | COUT_EXEC(3) |
---|
232 | #endif |
---|
233 | |
---|
234 | #if ORX_HARD_DEBUG_LEVEL >= ORX_DEBUG |
---|
235 | #define COUT4 \ |
---|
236 | if (getSoftDebugLevel() >= ORX_DEBUG) \ |
---|
237 | COUT_EXEC(4) |
---|
238 | #else |
---|
239 | #define COUT4 if (ORX_NONE) \ |
---|
240 | COUT_EXEC(4) |
---|
241 | #endif |
---|
242 | |
---|
243 | #if ORX_HARD_DEBUG_LEVEL >= ORX_vDEBUG |
---|
244 | #define COUT5 \ |
---|
245 | if (getSoftDebugLevel() >= ORX_vDEBUG) \ |
---|
246 | COUT_EXEC(5) |
---|
247 | #else |
---|
248 | #define COUT5 if (ORX_NONE) \ |
---|
249 | COUT_EXEC(5) |
---|
250 | #endif |
---|
251 | |
---|
252 | #else /* if ORX_PRINT_DEBUG_OUTPUT */ |
---|
253 | #define COUT(x) if (ORX_NONE) \ |
---|
254 | COUT_EXEC(5) |
---|
255 | #endif /* if ORX_PRINT_DEBUG_OUTPUT */ |
---|
256 | |
---|
257 | #define COUT0 \ |
---|
258 | COUT_EXEC(0) |
---|
259 | #endif /* ifndef COUT */ |
---|
260 | |
---|
261 | #endif /* _Debug_H__ */ |
---|