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