Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/shader/src/core/Debug.h @ 12397

Last change on this file since 12397 was 1505, checked in by rgrieder, 17 years ago

f* svn: It doesn't even inform you if you attempt to set a non existing property. It is svn:eol-style and not eol-style when using the command by the way…

  • Property svn:eol-style set to native
File size: 8.7 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Benjamin Grauer
24 *   Co-authors:
25 *      Fabian 'x3n' Landau
26 *
27 */
28
29/**
30 * @file Debug.h
31 * @brief Handles the output for different verbose-modes.
32 *
33 * There are two modes: HARD and SOFT. HARD is precessed during compiletime, while SOFT is for runtime.
34 */
35
36#ifndef _Debug_H__
37#define _Debug_H__
38
39#include "CorePrereqs.h"
40
41#include <stdio.h>
42
43#include "OutputHandler.h"
44
45extern "C" _CoreExport int getSoftDebugLevel();
46
47// DEFINE ERROR MODES
48#define ORX_NONE            0
49#define ORX_ERROR           1
50#define ORX_WARNING         2
51#define ORX_INFO            3
52#define ORX_DEBUG           4
53#define ORX_vDEBUG          5
54
55//definitions
56#define ORX_PRINT_DEBUG_OUTPUT 1 // <-- fix that! should be a configurable setting
57
58#define ORX_HARD_DEBUG_LEVEL ORX_vDEBUG
59//#define ORX_SOFT_DEBUG_LEVEL ORX_WARNING // <-- fix that! should be a configurable setting
60
61///////////////////////////////////////////////////
62/// PRINTF: prints with filename and linenumber ///
63///////////////////////////////////////////////////
64#define PRINTFORX_NONE    PRINTF0
65#define PRINTFORX_ERROR   PRINTF1
66#define PRINTFORX_WARNING PRINTF2
67#define PRINTFORX_INFO    PRINTF3
68#define PRINTFORX_DEBUG   PRINTF4
69#define PRINTFORX_vDEBUG  PRINTF5
70
71#define PRINT_EXEC  printf
72#define COUT_EXEC(x) \
73  orxonox::OutputHandler::getOutStream().setOutputLevel(x)
74
75#ifndef PRINTF
76 #if ORX_PRINT_DEBUG_OUTPUT
77
78  #define PRINTF(x) \
79   PRINTF ## x
80
81  #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR
82   #define PRINTF1 \
83    if (getSoftDebugLevel() >= ORX_ERROR) \
84     printf("Error (in %s, line %d): ", __FILE__, __LINE__), PRINT_EXEC
85  #else
86   #define PRINTF1 if (ORX_NONE) PRINT_EXEC
87  #endif
88
89  #if ORX_HARD_DEBUG_LEVEL >= ORX_WARNING
90   #define PRINTF2 \
91    if (getSoftDebugLevel() >= ORX_WARNING) \
92     printf("Warning (in %s, line %d): ", __FILE__, __LINE__), PRINT_EXEC
93  #else
94   #define PRINTF2 if (ORX_NONE) PRINT_EXEC
95  #endif
96
97  #if ORX_HARD_DEBUG_LEVEL >= ORX_INFO
98   #define PRINTF3 \
99    if (getSoftDebugLevel() >= ORX_INFO) \
100     printf("Info (in %s, line %d): ", __FILE__, __LINE__), PRINT_EXEC
101  #else
102   #define PRINTF3 if (ORX_NONE) PRINT_EXEC
103  #endif
104
105  #if ORX_HARD_DEBUG_LEVEL >= ORX_DEBUG
106   #define PRINTF4 \
107    if (getSoftDebugLevel() >= ORX_DEBUG) \
108     printf("Debug (in %s, line %d): ", __FILE__, __LINE__), PRINT_EXEC
109  #else
110   #define PRINTF4 if (ORX_NONE) PRINT_EXEC
111  #endif
112
113  #if ORX_HARD_DEBUG_LEVEL >= ORX_vDEBUG
114   #define PRINTF5 \
115    if (getSoftDebugLevel() >= ORX_vDEBUG) \
116     printf("vDebug (in %s, line %d): ", __FILE__, __LINE__), PRINT_EXEC
117  #else
118   #define PRINTF5 if (ORX_NONE) PRINT_EXEC
119  #endif
120
121 #else /* if ORX_PRINT_DEBUG_OUTPUT */
122  #define PRINTF(x) if (ORX_NONE) PRINT_EXEC
123 #endif /* if ORX_PRINT_DEBUG_OUTPUT */
124
125 #define PRINTF0 \
126  PRINT_EXEC
127#endif /* ifndef PRINTF */
128
129///////////////////////////////////////////////////
130///  PRINT: just prints output as is            ///
131///////////////////////////////////////////////////
132#define PRINTORX_NONE    PRINT0
133#define PRINTORX_ERROR   PRINT1
134#define PRINTORX_WARNING PRINT2
135#define PRINTORX_INFO    PRINT3
136#define PRINTORX_DEBUG   PRINT4
137#define PRINTORX_vDEBUG  PRINT5
138
139#ifndef PRINT
140 #if ORX_PRINT_DEBUG_OUTPUT
141  #define PRINT(x) \
142   PRINT ## x
143
144  #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR
145   #define PRINT1  \
146    if (getSoftDebugLevel() >= ORX_ERROR)  \
147     PRINT_EXEC
148  #else
149   #define PRINT1 if (ORX_NONE) PRINT_EXEC
150  #endif
151
152  #if ORX_HARD_DEBUG_LEVEL >= ORX_WARNING
153   #define PRINT2 \
154    if (getSoftDebugLevel() >= ORX_WARNING) \
155     PRINT_EXEC
156  #else
157   #define PRINT2 if (ORX_NONE) PRINT_EXEC
158  #endif
159
160  #if ORX_HARD_DEBUG_LEVEL >= ORX_INFO
161   #define PRINT3 \
162    if (getSoftDebugLevel() >= ORX_INFO) \
163     PRINT_EXEC
164  #else
165   #define PRINT3 if (ORX_NONE) PRINT_EXEC
166  #endif
167
168  #if ORX_HARD_DEBUG_LEVEL >= ORX_DEBUG
169   #define PRINT4 \
170    if (getSoftDebugLevel() >= ORX_DEBUG) \
171     PRINT_EXEC
172  #else
173   #define PRINT4 if (ORX_NONE) PRINT_EXEC
174  #endif
175
176  #if ORX_HARD_DEBUG_LEVEL >= ORX_vDEBUG
177   #define PRINT5 \
178    if (getSoftDebugLevel() >= ORX_vDEBUG) \
179     PRINT_EXEC
180  #else
181   #define PRINT5 if (ORX_NONE) PRINT_EXEC
182  #endif
183
184 #else /* if ORX_PRINT_DEBUG_OUTPUT */
185  #define PRINT(x) if (ORX_NONE) PRINT_EXEC
186 #endif /* if ORX_PRINT_DEBUG_OUTPUT */
187
188 #define PRINT0 \
189  PRINT_EXEC
190#endif /* ifndef PRINT */
191
192
193////////////////////////////////////////////////////////
194///  COUT: just prints output as is with std::cout   ///
195////////////////////////////////////////////////////////
196#define COUTORX_NONE    COUT0
197#define COUTORX_ERROR   COUT1
198#define COUTORX_WARNING COUT2
199#define COUTORX_INFO    COUT3
200#define COUTORX_DEBUG   COUT4
201#define COUTORX_vDEBUG  COUT5
202
203#ifndef COUT
204 #if ORX_PRINT_DEBUG_OUTPUT
205  #define COUT(x) \
206   COUT ## x
207
208  #if ORX_HARD_DEBUG_LEVEL >= ORX_NONE
209   #define COUT0  \
210    if (getSoftDebugLevel() >= ORX_NONE)  \
211     COUT_EXEC(0)
212  #else
213   #define COUT0 if (ORX_NONE)\
214    COUT_EXEC(0)
215  #endif
216
217  #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR
218   #define COUT1  \
219    if (getSoftDebugLevel() >= ORX_ERROR)  \
220     COUT_EXEC(1)
221  #else
222   #define COUT1 if (ORX_NONE)\
223    COUT_EXEC(1)
224  #endif
225
226  #if ORX_HARD_DEBUG_LEVEL >= ORX_WARNING
227   #define COUT2 \
228    if (getSoftDebugLevel() >= ORX_WARNING) \
229     COUT_EXEC(2)
230  #else
231   #define COUT2 if (ORX_NONE) \
232    COUT_EXEC(2)
233  #endif
234
235  #if ORX_HARD_DEBUG_LEVEL >= ORX_INFO
236   #define COUT3 \
237    if (getSoftDebugLevel() >= ORX_INFO) \
238     COUT_EXEC(3)
239  #else
240   #define COUT3 if (ORX_NONE) \
241    COUT_EXEC(3)
242  #endif
243
244  #if ORX_HARD_DEBUG_LEVEL >= ORX_DEBUG
245   #define COUT4 \
246    if (getSoftDebugLevel() >= ORX_DEBUG) \
247     COUT_EXEC(4)
248  #else
249   #define COUT4 if (ORX_NONE) \
250    COUT_EXEC(4)
251  #endif
252
253  #if ORX_HARD_DEBUG_LEVEL >= ORX_vDEBUG
254   #define COUT5 \
255    if (getSoftDebugLevel() >= ORX_vDEBUG) \
256     COUT_EXEC(5)
257  #else
258   #define COUT5 if (ORX_NONE) \
259    COUT_EXEC(5)
260  #endif
261
262 #else /* if ORX_PRINT_DEBUG_OUTPUT */
263  #define COUT(x) if (ORX_NONE) \
264   COUT_EXEC(5)
265 #endif /* if ORX_PRINT_DEBUG_OUTPUT */
266
267#endif /* ifndef COUT */
268
269
270/////////////////////////////////////////////////////////////////////
271///  CCOUT: Prints output with std::cout and adds the classname   ///
272/////////////////////////////////////////////////////////////////////
273#define CCOUTORX_NONE    CCOUT0
274#define CCOUTORX_ERROR   CCOUT1
275#define CCOUTORX_WARNING CCOUT2
276#define CCOUTORX_INFO    CCOUT3
277#define CCOUTORX_DEBUG   CCOUT4
278#define CCOUTORX_vDEBUG  CCOUT5
279
280#define CCOUT_EXEC(x) \
281  orxonox::OutputHandler::getOutStream().setOutputLevel(x) \
282  << this->getIdentifier()->getName() << ": "
283
284#ifndef CCOUT
285 #if ORX_PRINT_DEBUG_OUTPUT
286  #define CCOUT(x) \
287   CCOUT ## x
288
289  #if ORX_HARD_DEBUG_LEVEL >= ORX_NONE
290   #define CCOUT0  \
291    if (getSoftDebugLevel() >= ORX_NONE)  \
292     CCOUT_EXEC(0)
293  #else
294   #define CCOUT0 if (ORX_NONE)\
295    CCOUT_EXEC(0)
296  #endif
297
298  #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR
299   #define CCOUT1  \
300    if (getSoftDebugLevel() >= ORX_ERROR)  \
301     CCOUT_EXEC(1)
302  #else
303   #define CCOUT1 if (ORX_NONE)\
304    CCOUT_EXEC(1)
305  #endif
306
307  #if ORX_HARD_DEBUG_LEVEL >= ORX_WARNING
308   #define CCOUT2 \
309    if (getSoftDebugLevel() >= ORX_WARNING) \
310     CCOUT_EXEC(2)
311  #else
312   #define CCOUT2 if (ORX_NONE) \
313    CCOUT_EXEC(2)
314  #endif
315
316  #if ORX_HARD_DEBUG_LEVEL >= ORX_INFO
317   #define CCOUT3 \
318    if (getSoftDebugLevel() >= ORX_INFO) \
319     CCOUT_EXEC(3)
320  #else
321   #define CCOUT3 if (ORX_NONE) \
322    CCOUT_EXEC(3)
323  #endif
324
325  #if ORX_HARD_DEBUG_LEVEL >= ORX_DEBUG
326   #define CCOUT4 \
327    if (getSoftDebugLevel() >= ORX_DEBUG) \
328     CCOUT_EXEC(4)
329  #else
330   #define CCOUT4 if (ORX_NONE) \
331    CCOUT_EXEC(4)
332  #endif
333
334  #if ORX_HARD_DEBUG_LEVEL >= ORX_vDEBUG
335   #define CCOUT5 \
336    if (getSoftDebugLevel() >= ORX_vDEBUG) \
337     CCOUT_EXEC(5)
338  #else
339   #define CCOUT5 if (ORX_NONE) \
340    CCOUT_EXEC(5)
341  #endif
342
343 #else /* if ORX_PRINT_DEBUG_OUTPUT */
344  #define CCOUT(x) if (ORX_NONE) \
345   CCOUT_EXEC(5)
346 #endif /* if ORX_PRINT_DEBUG_OUTPUT */
347
348#endif /* ifndef CCOUT */
349
350#endif /* _Debug_H__ */
Note: See TracBrowser for help on using the repository browser.