Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/defs/debug.h @ 7813

Last change on this file since 7813 was 7729, checked in by bensch, 19 years ago

orxonox/trunk: better debug names
As DEBUG and ERROR are already given to windows.h and other files:
DEBUG is renamed to DEBUG_LEVEL
and all
NO, ERR, WARN, INFO, DEBUG, vDEBUG
are renamed to
ORX_NONE, ORX_ERR, ORX_WARN, ORX_INFO, ORX_DEBUG, ORX_vDEBUG

File size: 7.1 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_SPATIAL_SEPARATION    2
82  #define DEBUG_MODULE_GUI                   2
83  #define DEBUG_MODULE_SOUND                 2
84
85  // MISC
86  #define DEBUG_MODULE_TRACK_MANAGER         2
87  #define DEBUG_MODULE_MATH                  2
88
89  #define DEBUG_MODULE_PNODE                 2
90  #define DEBUG_MODULE_WORLD_ENTITY          2
91
92  #define DEBUG_MODULE_STORY_ENTITY          2
93  #define DEBUG_MODULE_GAME_RULES            2
94
95  #define DEBUG_MODULE_WEAPON                2
96
97  #define HARD_DEBUG_LEVEL DEBUG_SPECIAL_MODULE
98
99 #endif /* DEBUG_SPECIAL_MODULE */
100#endif /* MODULAR_DEBUG */
101
102///////////////////////////////////////////////////
103/// PRINTF: prints with filename and linenumber ///
104///////////////////////////////////////////////////
105#define PRINTFORX_NONE    PRINTF0
106#define PRINTFORX_ERR     PRINTF1
107#define PRINTFORX_WARN    PRINTF2
108#define PRINTFORX_INFO    PRINTF3
109#define PRINTFORX_DEBUG   PRINTF4
110#define PRINTFORX_VDEBUG  PRINTF5
111
112#if DEBUG_LEVEL <= 3
113#define PRINTF(x)        PRINT(x)
114#endif
115#ifndef NO_SHELL
116#define PRINT_EXEC       OrxShell::ShellBuffer::addBufferLineStatic
117#define COUT_EXEC        std::cout
118#else /* NO_SHELL */
119#define PRINT_EXEC       printf
120#define COUT_EXEC        std::cout
121#endif
122
123#ifndef PRINTF
124#ifdef ORX_DEBUG
125
126#define PRINTF(x) \
127           PRINTF ## x
128
129#if HARD_DEBUG_LEVEL >= ORX_ERR
130#define PRINTF1 \
131    if (SOFT_DEBUG_LEVEL >= ORX_ERR) \
132      printf("(EE)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC
133#else
134#define PRINTF1 if (ORX_NONE)
135#endif
136
137#if HARD_DEBUG_LEVEL >= ORX_WARN
138#define PRINTF2 \
139     if (SOFT_DEBUG_LEVEL >= ORX_WARN) \
140       printf("(WW)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC
141
142#else
143#define PRINTF2 if (ORX_NONE)
144#endif
145
146#if HARD_DEBUG_LEVEL >= ORX_INFO
147#define PRINTF3 \
148     if (SOFT_DEBUG_LEVEL >= ORX_INFO) \
149       printf("(II)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC
150#else
151#define PRINTF3 if (ORX_NONE)
152#endif
153
154#if HARD_DEBUG_LEVEL >= ORX_DEBUG
155#define PRINTF4 \
156     if (SOFT_DEBUG_LEVEL >= ORX_DEBUG) \
157       printf("(DD)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC
158#else
159#define PRINTF4 if (ORX_NONE)
160#endif
161
162#if HARD_DEBUG_LEVEL >= ORX_vDEBUG
163#define PRINTF5 \
164     if (SOFT_DEBUG_LEVEL >= ORX_vDEBUG) \
165       printf("(VD)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC
166#else
167#define PRINTF5 if (ORX_NONE)
168#endif
169
170#else
171#define PRINTF(x) if (ORX_NONE)
172#endif
173
174#define PRINTF0 \
175    printf("%s:%d::", __FILE__, __LINE__) && PRINT_EXEC
176#endif
177
178///////////////////////////////////////////////////
179///  PRINT: just prints output as is            ///
180///////////////////////////////////////////////////
181#define PRINTORX_NONE    PRINT0
182#define PRINTORX_ERR     PRINT1
183#define PRINTORX_WARN    PRINT2
184#define PRINTORX_INFO    PRINT3
185#define PRINTORX_DEBUG   PRINT4
186#define PRINTORX_vDEBUG  PRINT5
187
188#ifdef  DEBUG_LEVEL
189#define PRINT(x) \
190  PRINT ## x
191
192#if HARD_DEBUG_LEVEL >= ORX_ERR
193#define PRINT1  \
194  if (SOFT_DEBUG_LEVEL >= ORX_ERR)  \
195    PRINT_EXEC
196#else
197#define PRINT1 if (ORX_NONE)
198#endif
199
200#if HARD_DEBUG_LEVEL >= ORX_WARN
201#define PRINT2 \
202  if (SOFT_DEBUG_LEVEL >= ORX_WARN) \
203    PRINT_EXEC
204
205#else
206#define PRINT2 if (ORX_NONE)
207#endif
208
209#if HARD_DEBUG_LEVEL >= ORX_INFO
210#define PRINT3 \
211  if (SOFT_DEBUG_LEVEL >= ORX_INFO) \
212    PRINT_EXEC
213#else
214#define PRINT3 if (ORX_NONE)
215#endif
216
217#if HARD_DEBUG_LEVEL >= ORX_DEBUG
218#define PRINT4 \
219  if (SOFT_DEBUG_LEVEL >= ORX_DEBUG) \
220    PRINT_EXEC
221#else
222#define PRINT4 if (ORX_NONE)
223#endif
224
225#if HARD_DEBUG_LEVEL >= ORX_vDEBUG
226#define PRINT5 \
227     if (SOFT_DEBUG_LEVEL >= ORX_vDEBUG) \
228       PRINT_EXEC
229#else
230#define PRINT5 if (ORX_NONE)
231#endif
232
233
234#else
235#define PRINT(x) if (ORX_NONE)
236#endif
237
238#define PRINT0 \
239  PRINT_EXEC
240
241
242
243////////////////////////////////////////////////////////
244///  COUT: just prints output as is with std::cout   ///
245////////////////////////////////////////////////////////
246#define COUTORX_NONE    COUT0
247#define COUTORX_ERR     COUT1
248#define COUTORX_WARN    COUT2
249#define COUTORX_INFO    COUT3
250#define COUTORX_DEBUG   COUT4
251#define COUTORX_vDEBUG  COUT5
252
253#ifdef  DEBUG_LEVEL
254#define COUT(x) \
255  COUT ## x
256
257#if HARD_DEBUG_LEVEL >= ORX_ERR
258#define COUT1  \
259  if (SOFT_DEBUG_LEVEL >= ORX_ERR)  \
260    COUT_EXEC
261#else
262#define COUT1 if (ORX_NONE)\
263    COUT_EXEC
264#endif
265
266#if HARD_DEBUG_LEVEL >= ORX_WARN
267#define COUT2 \
268  if (SOFT_DEBUG_LEVEL >= ORX_WARN) \
269    COUT_EXEC
270
271#else
272#define COUT2 if (ORX_NONE) \
273    COUT_EXEC
274#endif
275
276#if HARD_DEBUG_LEVEL >= ORX_INFO
277#define COUT3 \
278  if (SOFT_DEBUG_LEVEL >= ORX_INFO) \
279    COUT_EXEC
280#else
281#define COUT3 if (ORX_NONE) \
282    COUT_EXEC
283#endif
284
285#if HARD_DEBUG_LEVEL >= ORX_DEBUG
286#define COUT4 \
287  if (SOFT_DEBUG_LEVEL >= ORX_DEBUG) \
288    COUT_EXEC
289#else
290#define COUT4 if (ORX_NONE) \
291    COUT_EXEC
292#endif
293
294#if HARD_DEBUG_LEVEL >= ORX_vDEBUG
295#define COUT5 \
296     if (SOFT_DEBUG_LEVEL >= ORX_vDEBUG) \
297       COUT_EXEC
298#else
299#define COUT5 if (ORX_NONE) \
300    COUT_EXEC
301#endif
302
303
304#else
305#define COUT(x) if (ORX_NONE) \
306    COUT_EXEC
307#endif
308
309#define COUT0 \
310  COUT_EXEC
311
312
313#endif /* _DEBUG_H */
Note: See TracBrowser for help on using the repository browser.