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_buffer.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 | //////////////////// |
---|
58 | // DEFINE MODULES // |
---|
59 | //////////////////// |
---|
60 | // FRAMEWORK |
---|
61 | #define DEBUG_MODULE_BASE 2 |
---|
62 | #define DEBUG_MODULE_ORXONOX 2 |
---|
63 | #define DEBUG_MODULE_WORLD 2 |
---|
64 | #define DEBUG_MODULE_NETWORK 2 |
---|
65 | |
---|
66 | // LOADING |
---|
67 | #define DEBUG_MODULE_LOAD 2 |
---|
68 | #define DEBUG_MODULE_IMPORTER 2 |
---|
69 | |
---|
70 | // ENGINES |
---|
71 | #define DEBUG_MODULE_GRAPHICS 2 |
---|
72 | #define DEBUG_MODULE_EVENT 2 |
---|
73 | #define DEBUG_MODULE_PHYSICS 2 |
---|
74 | #define DEBUG_MODULE_GARBAGE_COLLECTOR 2 |
---|
75 | #define DEBUG_MODULE_OBJECT_MANAGER 2 |
---|
76 | #define DEBUG_MODULE_ANIM 2 |
---|
77 | #define DEBUG_MODULE_COLLISON_DETECTION 2 |
---|
78 | #define DEBUG_MODULE_SPATIAL_SEPARATION 2 |
---|
79 | #define DEBUG_MODULE_GUI 2 |
---|
80 | |
---|
81 | // MISC |
---|
82 | #define DEBUG_MODULE_TRACK_MANAGER 2 |
---|
83 | #define DEBUG_MODULE_MATH 2 |
---|
84 | |
---|
85 | #define DEBUG_MODULE_PNODE 2 |
---|
86 | #define DEBUG_MODULE_WORLD_ENTITY 2 |
---|
87 | |
---|
88 | #define DEBUG_MODULE_WEAPON 2 |
---|
89 | |
---|
90 | #define HARD_DEBUG_LEVEL DEBUG_SPECIAL_MODULE |
---|
91 | |
---|
92 | #endif /* DEBUG_SPECIAL_MODULE */ |
---|
93 | #endif /* MODULAR_DEBUG */ |
---|
94 | |
---|
95 | /////////////////////////////////////////////////// |
---|
96 | /// PRINTF: prints with filename and linenumber /// |
---|
97 | /////////////////////////////////////////////////// |
---|
98 | #define PRINTFNO PRINTF0 |
---|
99 | #define PRINTFERR PRINTF1 |
---|
100 | #define PRINTFWARN PRINTF2 |
---|
101 | #define PRINTFINFO PRINTF3 |
---|
102 | #define PRINTFDEBUG PRINTF4 |
---|
103 | #define PRINTFVDEBUG PRINTF5 |
---|
104 | |
---|
105 | #if DEBUG <= 3 |
---|
106 | #define PRINTF(x) PRINT(x) |
---|
107 | #endif |
---|
108 | #ifndef NO_SHELL |
---|
109 | #define PRINT_EXEC ShellBuffer::addBufferLineStatic |
---|
110 | #else /* NO_SHELL */ |
---|
111 | #define PRINT_EXEC printf |
---|
112 | #endif |
---|
113 | |
---|
114 | #ifndef PRINTF |
---|
115 | #ifdef DEBUG |
---|
116 | |
---|
117 | #define PRINTF(x) \ |
---|
118 | PRINTF ## x |
---|
119 | |
---|
120 | #if HARD_DEBUG_LEVEL >= ERR |
---|
121 | #define PRINTF1 \ |
---|
122 | if (SOFT_DEBUG_LEVEL >= ERR) \ |
---|
123 | printf("(EE)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC |
---|
124 | #else |
---|
125 | #define PRINTF1 if (NO) |
---|
126 | #endif |
---|
127 | |
---|
128 | #if HARD_DEBUG_LEVEL >= WARN |
---|
129 | #define PRINTF2 \ |
---|
130 | if (SOFT_DEBUG_LEVEL >= WARN) \ |
---|
131 | printf("(WW)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC |
---|
132 | |
---|
133 | #else |
---|
134 | #define PRINTF2 if (NO) |
---|
135 | #endif |
---|
136 | |
---|
137 | #if HARD_DEBUG_LEVEL >= INFO |
---|
138 | #define PRINTF3 \ |
---|
139 | if (SOFT_DEBUG_LEVEL >= INFO) \ |
---|
140 | printf("(II)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC |
---|
141 | #else |
---|
142 | #define PRINTF3 if (NO) |
---|
143 | #endif |
---|
144 | |
---|
145 | #if HARD_DEBUG_LEVEL >= DEBUG |
---|
146 | #define PRINTF4 \ |
---|
147 | if (SOFT_DEBUG_LEVEL >= DEBUG) \ |
---|
148 | printf("(DD)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC |
---|
149 | #else |
---|
150 | #define PRINTF4 if (NO) |
---|
151 | #endif |
---|
152 | |
---|
153 | #if HARD_DEBUG_LEVEL >= vDEBUG |
---|
154 | #define PRINTF5 \ |
---|
155 | if (SOFT_DEBUG_LEVEL >= vDEBUG) \ |
---|
156 | printf("(VD)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC |
---|
157 | #else |
---|
158 | #define PRINTF5 if (NO) |
---|
159 | #endif |
---|
160 | |
---|
161 | #else |
---|
162 | #define PRINTF(x) if (NO) |
---|
163 | #endif |
---|
164 | |
---|
165 | #define PRINTF0 \ |
---|
166 | printf("%s:%d::", __FILE__, __LINE__) && PRINT_EXEC |
---|
167 | #endif |
---|
168 | |
---|
169 | /////////////////////////////////////////////////// |
---|
170 | /// PRINT: just prints output as is /// |
---|
171 | /////////////////////////////////////////////////// |
---|
172 | #define PRINTNO PRINT0 |
---|
173 | #define PRINTERR PRINT1 |
---|
174 | #define PRINTWARN PRINT2 |
---|
175 | #define PRINTINFO PRINT3 |
---|
176 | #define PRINTDEBUG PRINT4 |
---|
177 | #define PRINTVDEBUG PRINT5 |
---|
178 | |
---|
179 | #ifdef DEBUG |
---|
180 | #define PRINT(x) \ |
---|
181 | PRINT ## x |
---|
182 | |
---|
183 | #if HARD_DEBUG_LEVEL >= ERR |
---|
184 | #define PRINT1 \ |
---|
185 | if (SOFT_DEBUG_LEVEL >= ERR) \ |
---|
186 | PRINT_EXEC |
---|
187 | #else |
---|
188 | #define PRINT1 if (NO) |
---|
189 | #endif |
---|
190 | |
---|
191 | #if HARD_DEBUG_LEVEL >= WARN |
---|
192 | #define PRINT2 \ |
---|
193 | if (SOFT_DEBUG_LEVEL >= WARN) \ |
---|
194 | PRINT_EXEC |
---|
195 | |
---|
196 | #else |
---|
197 | #define PRINT2 if (NO) |
---|
198 | #endif |
---|
199 | |
---|
200 | #if HARD_DEBUG_LEVEL >= INFO |
---|
201 | #define PRINT3 \ |
---|
202 | if (SOFT_DEBUG_LEVEL >= INFO) \ |
---|
203 | PRINT_EXEC |
---|
204 | #else |
---|
205 | #define PRINT3 if (NO) |
---|
206 | #endif |
---|
207 | |
---|
208 | #if HARD_DEBUG_LEVEL >= DEBUG |
---|
209 | #define PRINT4 \ |
---|
210 | if (SOFT_DEBUG_LEVEL >= DEBUG) \ |
---|
211 | PRINT_EXEC |
---|
212 | #else |
---|
213 | #define PRINT4 if (NO) |
---|
214 | #endif |
---|
215 | |
---|
216 | #if HARD_DEBUG_LEVEL >= vDEBUG |
---|
217 | #define PRINT5 \ |
---|
218 | if (SOFT_DEBUG_LEVEL >= vDEBUG) \ |
---|
219 | PRINT_EXEC |
---|
220 | #else |
---|
221 | #define PRINT5 if (NO) |
---|
222 | #endif |
---|
223 | |
---|
224 | |
---|
225 | #else |
---|
226 | #define PRINT(x) if (NO) |
---|
227 | #endif |
---|
228 | |
---|
229 | #define PRINT0 \ |
---|
230 | PRINT_EXEC |
---|
231 | |
---|
232 | #endif /* _DEBUG_H */ |
---|