Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

using vector instead of list in classList

File size: 6.8 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  *  Handles 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 "shell_buffer.h"
31#endif /* NO_SHELL */
32
33#include <stdio.h>
34#include <cassert>
35#include <iostream>
36
37// DEFINE ERROR MODES
38#define NO              0
39#define ERR             1
40#define WARN            2
41#define INFO            3
42//#define DEBUG           4
43#define vDEBUG          5
44
45extern int verbose;
46
47//definitions
48#ifndef MODULAR_DEBUG
49 #define HARD_DEBUG_LEVEL DEBUG
50 #define SOFT_DEBUG_LEVEL verbose
51#else /* MODULAR_DEBUG */
52 #ifndef DEBUG_MODULE_SOFT
53  #define SOFT_DEBUG_LEVEL verbose
54 #else /* DEBUG_MODULE_SOFT */
55  #define SOFT_DEBUG_LEVEL DEBUG_MODULE_SOFT
56 #endif /* DEBUG_MODULE_SOFT */
57
58 #ifndef DEBUG_SPECIAL_MODULE
59  #define HARD_DEBUG_LEVEL DEBUG
60 #else /* DEBUG_SPECIAL_MODULE */
61  ////////////////////
62  // DEFINE MODULES //
63  ////////////////////
64  // FRAMEWORK
65  #define DEBUG_MODULE_BASE                  2
66  #define DEBUG_MODULE_ORXONOX               2
67  #define DEBUG_MODULE_WORLD                 2
68  #define DEBUG_MODULE_NETWORK               2
69
70  // LOADING
71  #define DEBUG_MODULE_LOAD                  2
72  #define DEBUG_MODULE_IMPORTER              2
73
74  // ENGINES
75  #define DEBUG_MODULE_GRAPHICS              2
76  #define DEBUG_MODULE_EVENT                 2
77  #define DEBUG_MODULE_PHYSICS               2
78  #define DEBUG_MODULE_GARBAGE_COLLECTOR     2
79  #define DEBUG_MODULE_OBJECT_MANAGER        2
80  #define DEBUG_MODULE_ANIM                  2
81  #define DEBUG_MODULE_COLLISON_DETECTION    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 PRINTFNO      PRINTF0
107#define PRINTFERR     PRINTF1
108#define PRINTFWARN    PRINTF2
109#define PRINTFINFO    PRINTF3
110#define PRINTFDEBUG   PRINTF4
111#define PRINTFVDEBUG  PRINTF5
112
113#if DEBUG <= 3
114#define PRINTF(x)        PRINT(x)
115#endif
116#ifndef NO_SHELL
117#define PRINT_EXEC       ShellBuffer::addBufferLineStatic
118#define COUT_EXEC        std::cout
119#else /* NO_SHELL */
120#define PRINT_EXEC       printf
121#define COUT_EXEC        std::cout
122#endif
123
124#ifndef PRINTF
125#ifdef DEBUG
126
127#define PRINTF(x) \
128           PRINTF ## x
129
130#if HARD_DEBUG_LEVEL >= ERR
131#define PRINTF1 \
132    if (SOFT_DEBUG_LEVEL >= ERR) \
133      printf("(EE)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC
134#else
135#define PRINTF1 if (NO)
136#endif
137
138#if HARD_DEBUG_LEVEL >= WARN
139#define PRINTF2 \
140     if (SOFT_DEBUG_LEVEL >= WARN) \
141       printf("(WW)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC
142
143#else
144#define PRINTF2 if (NO)
145#endif
146
147#if HARD_DEBUG_LEVEL >= INFO
148#define PRINTF3 \
149     if (SOFT_DEBUG_LEVEL >= INFO) \
150       printf("(II)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC
151#else
152#define PRINTF3 if (NO)
153#endif
154
155#if HARD_DEBUG_LEVEL >= DEBUG
156#define PRINTF4 \
157     if (SOFT_DEBUG_LEVEL >= DEBUG) \
158       printf("(DD)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC
159#else
160#define PRINTF4 if (NO)
161#endif
162
163#if HARD_DEBUG_LEVEL >= vDEBUG
164#define PRINTF5 \
165     if (SOFT_DEBUG_LEVEL >= vDEBUG) \
166       printf("(VD)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC
167#else
168#define PRINTF5 if (NO)
169#endif
170
171#else
172#define PRINTF(x) if (NO)
173#endif
174
175#define PRINTF0 \
176    printf("%s:%d::", __FILE__, __LINE__) && PRINT_EXEC
177#endif
178
179///////////////////////////////////////////////////
180///  PRINT: just prints output as is            ///
181///////////////////////////////////////////////////
182#define PRINTNO      PRINT0
183#define PRINTERR     PRINT1
184#define PRINTWARN    PRINT2
185#define PRINTINFO    PRINT3
186#define PRINTDEBUG   PRINT4
187#define PRINTVDEBUG  PRINT5
188
189#ifdef  DEBUG
190#define PRINT(x) \
191  PRINT ## x
192
193#if HARD_DEBUG_LEVEL >= ERR
194#define PRINT1  \
195  if (SOFT_DEBUG_LEVEL >= ERR)  \
196    PRINT_EXEC
197#else
198#define PRINT1 if (NO)
199#endif
200
201#if HARD_DEBUG_LEVEL >= WARN
202#define PRINT2 \
203  if (SOFT_DEBUG_LEVEL >= WARN) \
204    PRINT_EXEC
205
206#else
207#define PRINT2 if (NO)
208#endif
209
210#if HARD_DEBUG_LEVEL >= INFO
211#define PRINT3 \
212  if (SOFT_DEBUG_LEVEL >= INFO) \
213    PRINT_EXEC
214#else
215#define PRINT3 if (NO)
216#endif
217
218#if HARD_DEBUG_LEVEL >= DEBUG
219#define PRINT4 \
220  if (SOFT_DEBUG_LEVEL >= DEBUG) \
221    PRINT_EXEC
222#else
223#define PRINT4 if (NO)
224#endif
225
226#if HARD_DEBUG_LEVEL >= vDEBUG
227#define PRINT5 \
228     if (SOFT_DEBUG_LEVEL >= vDEBUG) \
229       PRINT_EXEC
230#else
231#define PRINT5 if (NO)
232#endif
233
234
235#else
236#define PRINT(x) if (NO)
237#endif
238
239#define PRINT0 \
240  PRINT_EXEC
241
242
243
244////////////////////////////////////////////////////////
245///  COUT: just prints output as is with std::cout   ///
246////////////////////////////////////////////////////////
247#define COUTNO      COUT0
248#define COUTERR     COUT1
249#define COUTWARN    COUT2
250#define COUTINFO    COUT3
251#define COUTDEBUG   COUT4
252#define COUTVDEBUG  COUT5
253
254#ifdef  DEBUG
255#define COUT(x) \
256  COUT ## x
257
258#if HARD_DEBUG_LEVEL >= ERR
259#define COUT1  \
260  if (SOFT_DEBUG_LEVEL >= ERR)  \
261    COUT_EXEC
262#else
263#define COUT1 if (NO)\
264    COUT_EXEC
265#endif
266
267#if HARD_DEBUG_LEVEL >= WARN
268#define COUT2 \
269  if (SOFT_DEBUG_LEVEL >= WARN) \
270    COUT_EXEC
271
272#else
273#define COUT2 if (NO) \
274    COUT_EXEC
275#endif
276
277#if HARD_DEBUG_LEVEL >= INFO
278#define COUT3 \
279  if (SOFT_DEBUG_LEVEL >= INFO) \
280    COUT_EXEC
281#else
282#define COUT3 if (NO) \
283    COUT_EXEC
284#endif
285
286#if HARD_DEBUG_LEVEL >= DEBUG
287#define COUT4 \
288  if (SOFT_DEBUG_LEVEL >= DEBUG) \
289    COUT_EXEC
290#else
291#define COUT4 if (NO) \
292    COUT_EXEC
293#endif
294
295#if HARD_DEBUG_LEVEL >= vDEBUG
296#define COUT5 \
297     if (SOFT_DEBUG_LEVEL >= vDEBUG) \
298       COUT_EXEC
299#else
300#define COUT5 if (NO) \
301    COUT_EXEC
302#endif
303
304
305#else
306#define COUT(x) if (NO) \
307    COUT_EXEC
308#endif
309
310#define COUT0 \
311  COUT_EXEC
312
313
314#endif /* _DEBUG_H */
Note: See TracBrowser for help on using the repository browser.