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 | #include "shell.h" |
---|
30 | |
---|
31 | #include <stdio.h> |
---|
32 | |
---|
33 | // DEFINE ERROR MODES |
---|
34 | #define NO 0 |
---|
35 | #define ERR 1 |
---|
36 | #define WARN 2 |
---|
37 | #define INFO 3 |
---|
38 | //#define DEBUG 4 |
---|
39 | #define vDEBUG 5 |
---|
40 | |
---|
41 | extern int verbose; |
---|
42 | |
---|
43 | //definitions |
---|
44 | #ifndef MODULAR_DEBUG |
---|
45 | #define HARD_DEBUG_LEVEL DEBUG |
---|
46 | #define SOFT_DEBUG_LEVEL verbose |
---|
47 | #else /* MODULAR_DEBUG */ |
---|
48 | #ifndef DEBUG_MODULE_SOFT |
---|
49 | #define SOFT_DEBUG_LEVEL verbose |
---|
50 | #else /* DEBUG_MODULE_SOFT */ |
---|
51 | #define SOFT_DEBUG_LEVEL DEBUG_MODULE_SOFT |
---|
52 | #endif /* DEBUG_MODULE_SOFT */ |
---|
53 | |
---|
54 | #ifndef DEBUG_SPECIAL_MODULE |
---|
55 | #define HARD_DEBUG_LEVEL DEBUG |
---|
56 | #else /* DEBUG_SPECIAL_MODULE */ |
---|
57 | // DEFINE MODULES |
---|
58 | #define DEBUG_MODULE_ORXONOX 2 |
---|
59 | #define DEBUG_MODULE_WORLD 2 |
---|
60 | #define DEBUG_MODULE_PNODE 2 |
---|
61 | #define DEBUG_MODULE_WORLD_ENTITY 2 |
---|
62 | #define DEBUG_MODULE_COMMAND_NODE 2 |
---|
63 | #define DEBUG_MODULE_GRAPHICS 2 |
---|
64 | #define DEBUG_MODULE_LOAD 2 |
---|
65 | |
---|
66 | #define DEBUG_MODULE_IMPORTER 2 |
---|
67 | #define DEBUG_MODULE_TRACK_MANAGER 2 |
---|
68 | #define DEBUG_MODULE_GARBAGE_COLLECTOR 2 |
---|
69 | #define DEBUG_MODULE_OBJECT_MANAGER 2 |
---|
70 | #define DEBUG_MODULE_LIGHT 2 |
---|
71 | #define DEBUG_MODULE_PLAYER 2 |
---|
72 | #define DEBUG_MODULE_WEAPON 2 |
---|
73 | #define DEBUG_MODULE_MATH 2 |
---|
74 | #define DEBUG_MODULE_FONT 2 |
---|
75 | #define DEBUG_MODULE_ANIM 2 |
---|
76 | #define DEBUG_MODULE_PARTICLE 2 |
---|
77 | #define DEBUG_MODULE_PHYSICS 2 |
---|
78 | #define DEBUG_MODULE_EVENT 2 |
---|
79 | |
---|
80 | #define DEBUG_MODULE_NULL_PARENT 2 |
---|
81 | #define DEBUG_MODULE_NETWORK 2 |
---|
82 | |
---|
83 | #define DEBUG_MODULE_COLLISON_DETECTION 2 |
---|
84 | #define DEBUG_MODULE_SPATIAL_SEPARATION 2 |
---|
85 | |
---|
86 | #define HARD_DEBUG_LEVEL DEBUG_SPECIAL_MODULE |
---|
87 | #endif /* DEBUG_SPECIAL_MODULE */ |
---|
88 | #endif /* MODULAR_DEBUG */ |
---|
89 | |
---|
90 | /////////////////////////////////////////////////// |
---|
91 | /// PRINTF: prints with filename and linenumber /// |
---|
92 | /////////////////////////////////////////////////// |
---|
93 | #define PRINTFNO PRINTF0 |
---|
94 | #define PRINTFERR PRINTF1 |
---|
95 | #define PRINTFWARN PRINTF2 |
---|
96 | #define PRINTFINFO PRINTF3 |
---|
97 | #define PRINTFDEBUG PRINTF4 |
---|
98 | #define PRINTFVDEBUG PRINTF5 |
---|
99 | |
---|
100 | //#ifdef |
---|
101 | #define PRINTF(x) PRINT(x) |
---|
102 | #define PRINT_EXEC Shell::addBufferLineStatic |
---|
103 | |
---|
104 | #ifndef PRINTF |
---|
105 | #ifdef DEBUG |
---|
106 | |
---|
107 | #define PRINTF(x) \ |
---|
108 | PRINTF ## x |
---|
109 | |
---|
110 | #if HARD_DEBUG_LEVEL >= ERR |
---|
111 | #define PRINTF1 \ |
---|
112 | if (SOFT_DEBUG_LEVEL >= ERR) \ |
---|
113 | printf("ERROR::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC |
---|
114 | #else |
---|
115 | #define PRINTF1 if (NO) |
---|
116 | #endif |
---|
117 | |
---|
118 | #if HARD_DEBUG_LEVEL >= WARN |
---|
119 | #define PRINTF2 \ |
---|
120 | if (SOFT_DEBUG_LEVEL >= WARN) \ |
---|
121 | printf("WARNING::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC |
---|
122 | |
---|
123 | #else |
---|
124 | #define PRINTF2 if (NO) |
---|
125 | #endif |
---|
126 | |
---|
127 | #if HARD_DEBUG_LEVEL >= INFO |
---|
128 | #define PRINTF3 \ |
---|
129 | if (SOFT_DEBUG_LEVEL >= INFO) \ |
---|
130 | printf("INFO::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC |
---|
131 | #else |
---|
132 | #define PRINTF3 if (NO) |
---|
133 | #endif |
---|
134 | |
---|
135 | #if HARD_DEBUG_LEVEL >= DEBUG |
---|
136 | #define PRINTF4 \ |
---|
137 | if (SOFT_DEBUG_LEVEL >= DEBUG) \ |
---|
138 | printf("DEBUG::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC |
---|
139 | #else |
---|
140 | #define PRINTF4 if (NO) |
---|
141 | #endif |
---|
142 | |
---|
143 | #if HARD_DEBUG_LEVEL >= vDEBUG |
---|
144 | #define PRINTF5 \ |
---|
145 | if (SOFT_DEBUG_LEVEL >= vDEBUG) \ |
---|
146 | printf("VERYDEBUG::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC |
---|
147 | #else |
---|
148 | #define PRINTF5 if (NO) |
---|
149 | #endif |
---|
150 | |
---|
151 | #else |
---|
152 | #define PRINTF(x) if (NO) |
---|
153 | #endif |
---|
154 | |
---|
155 | #define PRINTF0 \ |
---|
156 | printf("%s:%d::", __FILE__, __LINE__) && PRINT_EXEC |
---|
157 | #endif |
---|
158 | |
---|
159 | /////////////////////////////////////////////////// |
---|
160 | /// PRINT: just prints output as is /// |
---|
161 | /////////////////////////////////////////////////// |
---|
162 | #define PRINTNO PRINT0 |
---|
163 | #define PRINTERR PRINT1 |
---|
164 | #define PRINTWARN PRINT2 |
---|
165 | #define PRINTINFO PRINT3 |
---|
166 | #define PRINTDEBUG PRINT4 |
---|
167 | #define PRINTVDEBUG PRINT5 |
---|
168 | |
---|
169 | #ifdef DEBUG |
---|
170 | #define PRINT(x) \ |
---|
171 | PRINT ## x |
---|
172 | |
---|
173 | #if HARD_DEBUG_LEVEL >= ERR |
---|
174 | #define PRINT1 \ |
---|
175 | if (SOFT_DEBUG_LEVEL >= ERR) \ |
---|
176 | PRINT_EXEC |
---|
177 | #else |
---|
178 | #define PRINT1 if (NO) |
---|
179 | #endif |
---|
180 | |
---|
181 | #if HARD_DEBUG_LEVEL >= WARN |
---|
182 | #define PRINT2 \ |
---|
183 | if (SOFT_DEBUG_LEVEL >= WARN) \ |
---|
184 | PRINT_EXEC |
---|
185 | |
---|
186 | #else |
---|
187 | #define PRINT2 if (NO) |
---|
188 | #endif |
---|
189 | |
---|
190 | #if HARD_DEBUG_LEVEL >= INFO |
---|
191 | #define PRINT3 \ |
---|
192 | if (SOFT_DEBUG_LEVEL >= INFO) \ |
---|
193 | PRINT_EXEC |
---|
194 | #else |
---|
195 | #define PRINT3 if (NO) |
---|
196 | #endif |
---|
197 | |
---|
198 | #if HARD_DEBUG_LEVEL >= DEBUG |
---|
199 | #define PRINT4 \ |
---|
200 | if (SOFT_DEBUG_LEVEL >= DEBUG) \ |
---|
201 | PRINT_EXEC |
---|
202 | #else |
---|
203 | #define PRINT4 if (NO) |
---|
204 | #endif |
---|
205 | |
---|
206 | #if HARD_DEBUG_LEVEL >= vDEBUG |
---|
207 | #define PRINT5 \ |
---|
208 | if (SOFT_DEBUG_LEVEL >= vDEBUG) \ |
---|
209 | PRINT_EXEC("VERYDEBUG::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC |
---|
210 | #else |
---|
211 | #define PRINT5 if (NO) |
---|
212 | #endif |
---|
213 | |
---|
214 | |
---|
215 | #else |
---|
216 | #define PRINT(x) if (NO) |
---|
217 | #endif |
---|
218 | |
---|
219 | #define PRINT0 \ |
---|
220 | PRINT_EXEC |
---|
221 | |
---|
222 | #endif /* _DEBUG_H */ |
---|