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