Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/terrain.old/src/defs/debug.h @ 9442

Last change on this file since 9442 was 9140, checked in by bensch, 18 years ago

merged back

File size: 7.4 KB
Line 
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 * @briefHandles output to console for different Verbose-Modes.
19 *
20 * There are two main modes HARD and SOFT. HARD is precessed during compileTime where SOFT is for runtime.
21 * @li HARD: One can choose between different modes. see: // DEFINE_MODULES
22 * @li SOFT: If you want each module can have its own variable for processing. just pass it to DEBUG_MODULE_SOFT
23 */
24
25#ifndef _DEBUG_H
26#define _DEBUG_H
27
28#include "confincl.h"
29#ifndef NO_SHELL
30#include "lib/shell/shell_buffer.h"
31#endif /* NO_SHELL */
32
33#include <stdio.h>
34#include <cassert>
35
36// DEFINE ERROR MODES
37#define ORX_NONE            0
38#define ORX_ERR             1
39#define ORX_WARN            2
40#define ORX_INFO            3
41#define ORX_DEBUG           4
42#define ORX_vDEBUG          5
43
44extern int verbose;
45
46//definitions
47#ifndef MODULAR_DEBUG
48 #define HARD_DEBUG_LEVEL ORX_DEBUG
49 #define SOFT_DEBUG_LEVEL verbose
50#else /* MODULAR_DEBUG */
51 #ifndef DEBUG_MODULE_SOFT
52  #define SOFT_DEBUG_LEVEL verbose
53 #else /* DEBUG_MODULE_SOFT */
54  #define SOFT_DEBUG_LEVEL DEBUG_MODULE_SOFT
55 #endif /* DEBUG_MODULE_SOFT */
56
57 #ifndef DEBUG_SPECIAL_MODULE
58  #define HARD_DEBUG_LEVEL DEBUG
59 #else /* DEBUG_SPECIAL_MODULE */
60  ////////////////////
61  // DEFINE MODULES //
62  ////////////////////
63  // FRAMEWORK
64  #define DEBUG_MODULE_BASE                  2
65  #define DEBUG_MODULE_ORXONOX               2
66  #define DEBUG_MODULE_WORLD                 2
67  #define DEBUG_MODULE_NETWORK               2
68
69  // LOADING
70  #define DEBUG_MODULE_LOAD                  2
71  #define DEBUG_MODULE_IMPORTER              2
72
73  // ENGINES
74  #define DEBUG_MODULE_GRAPHICS              2
75  #define DEBUG_MODULE_EVENT                 2
76  #define DEBUG_MODULE_PHYSICS               2
77  #define DEBUG_MODULE_GARBAGE_COLLECTOR     2
78  #define DEBUG_MODULE_OBJECT_MANAGER        2
79  #define DEBUG_MODULE_ANIM                  2
80  #define DEBUG_MODULE_COLLISION_DETECTION   2
81  #define DEBUG_MODULE_COLLISION_REACTION    2
82  #define DEBUG_MODULE_SPATIAL_SEPARATION    2
83  #define DEBUG_MODULE_GUI                   2
84  #define DEBUG_MODULE_SOUND                 2
85
86  // MISC
87  #define DEBUG_MODULE_TRACK_MANAGER         2
88  #define DEBUG_MODULE_MATH                  2
89
90  #define DEBUG_MODULE_PNODE                 2
91  #define DEBUG_MODULE_WORLD_ENTITY          2
92
93  #define DEBUG_MODULE_STORY_ENTITY          2
94  #define DEBUG_MODULE_GAME_RULES            2
95
96  #define DEBUG_MODULE_WEAPON                2
97
98  #define HARD_DEBUG_LEVEL DEBUG_SPECIAL_MODULE
99
100 #endif /* DEBUG_SPECIAL_MODULE */
101#endif /* MODULAR_DEBUG */
102
103///////////////////////////////////////////////////
104/// PRINTF: prints with filename and linenumber ///
105///////////////////////////////////////////////////
106#define PRINTFORX_NONE    PRINTF0
107#define PRINTFORX_ERR     PRINTF1
108#define PRINTFORX_WARN    PRINTF2
109#define PRINTFORX_INFO    PRINTF3
110#define PRINTFORX_DEBUG   PRINTF4
111#define PRINTFORX_VDEBUG  PRINTF5
112
113#ifndef ORX_DATADIR
114#define ORX_DATADIR "/usr/share"
115#endif
116#ifndef DEBUG_LEVEL
117#define DEBUG_LEVEL 2
118#endif
119#if DEBUG_LEVEL <= 3
120#define PRINTF(x)        PRINT(x)
121#endif
122#ifndef NO_SHELL
123#define PRINT_EXEC       OrxShell::ShellBuffer::addBufferLineStatic
124#define COUT_EXEC        std::cout
125#else /* NO_SHELL */
126#define PRINT_EXEC       printf
127#define COUT_EXEC        std::cout
128#endif
129
130#ifndef PRINTF
131#ifdef ORX_DEBUG
132
133#define PRINTF(x) \
134           PRINTF ## x
135
136#if HARD_DEBUG_LEVEL >= ORX_ERR
137#define PRINTF1 \
138    if (SOFT_DEBUG_LEVEL >= ORX_ERR) \
139      printf("(EE)::%s:%d:", __FILE__, __LINE__), PRINT_EXEC
140#else
141#define PRINTF1 if (ORX_NONE) PRINT_EXEC
142#endif
143
144#if HARD_DEBUG_LEVEL >= ORX_WARN
145#define PRINTF2 \
146     if (SOFT_DEBUG_LEVEL >= ORX_WARN) \
147       printf("(WW)::%s:%d:", __FILE__, __LINE__), PRINT_EXEC
148
149#else
150#define PRINTF2 if (ORX_NONE) PRINT_EXEC
151#endif
152
153#if HARD_DEBUG_LEVEL >= ORX_INFO
154#define PRINTF3 \
155     if (SOFT_DEBUG_LEVEL >= ORX_INFO) \
156       printf("(II)::%s:%d:", __FILE__, __LINE__), PRINT_EXEC
157#else
158#define PRINTF3 if (ORX_NONE) PRINT_EXEC
159#endif
160
161#if HARD_DEBUG_LEVEL >= ORX_DEBUG
162#define PRINTF4 \
163     if (SOFT_DEBUG_LEVEL >= ORX_DEBUG) \
164       printf("(DD)::%s:%d:", __FILE__, __LINE__), PRINT_EXEC
165#else
166#define PRINTF4 if (ORX_NONE) PRINT_EXEC
167#endif
168
169#if HARD_DEBUG_LEVEL >= ORX_vDEBUG
170#define PRINTF5 \
171     if (SOFT_DEBUG_LEVEL >= ORX_vDEBUG) \
172       printf("(VD)::%s:%d:", __FILE__, __LINE__), PRINT_EXEC
173#else
174#define PRINTF5 if (ORX_NONE) PRINT_EXEC
175#endif
176
177#else
178#define PRINTF(x) if (ORX_NONE) PRINT_EXEC
179#endif
180
181#define PRINTF0 \
182    printf("%s:%d::", __FILE__, __LINE__), PRINT_EXEC
183#endif
184
185///////////////////////////////////////////////////
186///  PRINT: just prints output as is            ///
187///////////////////////////////////////////////////
188#define PRINTORX_NONE    PRINT0
189#define PRINTORX_ERR     PRINT1
190#define PRINTORX_WARN    PRINT2
191#define PRINTORX_INFO    PRINT3
192#define PRINTORX_DEBUG   PRINT4
193#define PRINTORX_vDEBUG  PRINT5
194
195#ifdef  DEBUG_LEVEL
196#define PRINT(x) \
197  PRINT ## x
198
199#if HARD_DEBUG_LEVEL >= ORX_ERR
200#define PRINT1  \
201  if (SOFT_DEBUG_LEVEL >= ORX_ERR)  \
202    PRINT_EXEC
203#else
204#define PRINT1 if (ORX_NONE) PRINT_EXEC
205#endif
206
207#if HARD_DEBUG_LEVEL >= ORX_WARN
208#define PRINT2 \
209  if (SOFT_DEBUG_LEVEL >= ORX_WARN) \
210    PRINT_EXEC
211
212#else
213#define PRINT2 if (ORX_NONE) PRINT_EXEC
214#endif
215
216#if HARD_DEBUG_LEVEL >= ORX_INFO
217#define PRINT3 \
218  if (SOFT_DEBUG_LEVEL >= ORX_INFO) \
219    PRINT_EXEC
220#else
221#define PRINT3 if (ORX_NONE) PRINT_EXEC
222#endif
223
224#if HARD_DEBUG_LEVEL >= ORX_DEBUG
225#define PRINT4 \
226  if (SOFT_DEBUG_LEVEL >= ORX_DEBUG) \
227    PRINT_EXEC
228#else
229#define PRINT4 if (ORX_NONE) PRINT_EXEC
230#endif
231
232#if HARD_DEBUG_LEVEL >= ORX_vDEBUG
233#define PRINT5 \
234     if (SOFT_DEBUG_LEVEL >= ORX_vDEBUG) \
235       PRINT_EXEC
236#else
237#define PRINT5 if (ORX_NONE) PRINT_EXEC
238#endif
239
240
241#else
242#define PRINT(x) if (ORX_NONE) PRINT_EXEC
243#endif
244
245#define PRINT0 \
246  PRINT_EXEC
247
248
249
250////////////////////////////////////////////////////////
251///  COUT: just prints output as is with std::cout   ///
252////////////////////////////////////////////////////////
253#define COUTORX_NONE    COUT0
254#define COUTORX_ERR     COUT1
255#define COUTORX_WARN    COUT2
256#define COUTORX_INFO    COUT3
257#define COUTORX_DEBUG   COUT4
258#define COUTORX_vDEBUG  COUT5
259
260#ifdef  DEBUG_LEVEL
261#define COUT(x) \
262  COUT ## x
263
264#if HARD_DEBUG_LEVEL >= ORX_ERR
265#define COUT1  \
266  if (SOFT_DEBUG_LEVEL >= ORX_ERR)  \
267    COUT_EXEC
268#else
269#define COUT1 if (ORX_NONE)\
270    COUT_EXEC
271#endif
272
273#if HARD_DEBUG_LEVEL >= ORX_WARN
274#define COUT2 \
275  if (SOFT_DEBUG_LEVEL >= ORX_WARN) \
276    COUT_EXEC
277
278#else
279#define COUT2 if (ORX_NONE) \
280    COUT_EXEC
281#endif
282
283#if HARD_DEBUG_LEVEL >= ORX_INFO
284#define COUT3 \
285  if (SOFT_DEBUG_LEVEL >= ORX_INFO) \
286    COUT_EXEC
287#else
288#define COUT3 if (ORX_NONE) \
289    COUT_EXEC
290#endif
291
292#if HARD_DEBUG_LEVEL >= ORX_DEBUG
293#define COUT4 \
294  if (SOFT_DEBUG_LEVEL >= ORX_DEBUG) \
295    COUT_EXEC
296#else
297#define COUT4 if (ORX_NONE) \
298    COUT_EXEC
299#endif
300
301#if HARD_DEBUG_LEVEL >= ORX_vDEBUG
302#define COUT5 \
303     if (SOFT_DEBUG_LEVEL >= ORX_vDEBUG) \
304       COUT_EXEC
305#else
306#define COUT5 if (ORX_NONE) \
307    COUT_EXEC
308#endif
309
310
311#else
312#define COUT(x) if (ORX_NONE) \
313    COUT_EXEC
314#endif
315
316#define COUT0 \
317  COUT_EXEC
318
319
320#endif /* _DEBUG_H */
Note: See TracBrowser for help on using the repository browser.