Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7148 was 7020, checked in by patrick, 19 years ago

trunk: added the game rules

File size: 5.5 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
36// DEFINE ERROR MODES
37#define NO              0
38#define ERR             1
39#define WARN            2
40#define INFO            3
41//#define DEBUG           4
42#define vDEBUG          5
43
44extern int verbose;
45
46//definitions
47#ifndef MODULAR_DEBUG
48 #define HARD_DEBUG_LEVEL 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_COLLISON_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 PRINTFNO      PRINTF0
106#define PRINTFERR     PRINTF1
107#define PRINTFWARN    PRINTF2
108#define PRINTFINFO    PRINTF3
109#define PRINTFDEBUG   PRINTF4
110#define PRINTFVDEBUG  PRINTF5
111
112#if DEBUG <= 3
113#define PRINTF(x)        PRINT(x)
114#endif
115#ifndef NO_SHELL
116#define PRINT_EXEC       ShellBuffer::addBufferLineStatic
117#else /* NO_SHELL */
118#define PRINT_EXEC       printf
119#endif
120
121#ifndef PRINTF
122#ifdef DEBUG
123
124#define PRINTF(x) \
125           PRINTF ## x
126
127#if HARD_DEBUG_LEVEL >= ERR
128#define PRINTF1 \
129    if (SOFT_DEBUG_LEVEL >= ERR) \
130      printf("(EE)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC
131#else
132#define PRINTF1 if (NO)
133#endif
134
135#if HARD_DEBUG_LEVEL >= WARN
136#define PRINTF2 \
137     if (SOFT_DEBUG_LEVEL >= WARN) \
138       printf("(WW)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC
139
140#else
141#define PRINTF2 if (NO)
142#endif
143
144#if HARD_DEBUG_LEVEL >= INFO
145#define PRINTF3 \
146     if (SOFT_DEBUG_LEVEL >= INFO) \
147       printf("(II)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC
148#else
149#define PRINTF3 if (NO)
150#endif
151
152#if HARD_DEBUG_LEVEL >= DEBUG
153#define PRINTF4 \
154     if (SOFT_DEBUG_LEVEL >= DEBUG) \
155       printf("(DD)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC
156#else
157#define PRINTF4 if (NO)
158#endif
159
160#if HARD_DEBUG_LEVEL >= vDEBUG
161#define PRINTF5 \
162     if (SOFT_DEBUG_LEVEL >= vDEBUG) \
163       printf("(VD)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC
164#else
165#define PRINTF5 if (NO)
166#endif
167
168#else
169#define PRINTF(x) if (NO)
170#endif
171
172#define PRINTF0 \
173    printf("%s:%d::", __FILE__, __LINE__) && PRINT_EXEC
174#endif
175
176///////////////////////////////////////////////////
177///  PRINT: just prints output as is            ///
178///////////////////////////////////////////////////
179#define PRINTNO      PRINT0
180#define PRINTERR     PRINT1
181#define PRINTWARN    PRINT2
182#define PRINTINFO    PRINT3
183#define PRINTDEBUG   PRINT4
184#define PRINTVDEBUG  PRINT5
185
186#ifdef  DEBUG
187#define PRINT(x) \
188  PRINT ## x
189
190#if HARD_DEBUG_LEVEL >= ERR
191#define PRINT1  \
192  if (SOFT_DEBUG_LEVEL >= ERR)  \
193    PRINT_EXEC
194#else
195#define PRINT1 if (NO)
196#endif
197
198#if HARD_DEBUG_LEVEL >= WARN
199#define PRINT2 \
200  if (SOFT_DEBUG_LEVEL >= WARN) \
201    PRINT_EXEC
202
203#else
204#define PRINT2 if (NO)
205#endif
206
207#if HARD_DEBUG_LEVEL >= INFO
208#define PRINT3 \
209  if (SOFT_DEBUG_LEVEL >= INFO) \
210    PRINT_EXEC
211#else
212#define PRINT3 if (NO)
213#endif
214
215#if HARD_DEBUG_LEVEL >= DEBUG
216#define PRINT4 \
217  if (SOFT_DEBUG_LEVEL >= DEBUG) \
218    PRINT_EXEC
219#else
220#define PRINT4 if (NO)
221#endif
222
223#if HARD_DEBUG_LEVEL >= vDEBUG
224#define PRINT5 \
225     if (SOFT_DEBUG_LEVEL >= vDEBUG) \
226       PRINT_EXEC
227#else
228#define PRINT5 if (NO)
229#endif
230
231
232#else
233#define PRINT(x) if (NO)
234#endif
235
236#define PRINT0 \
237  PRINT_EXEC
238
239#endif /* _DEBUG_H */
Note: See TracBrowser for help on using the repository browser.