[4608] | 1 | /* |
---|
[3395] | 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 | |
---|
[4608] | 16 | /*! |
---|
[5039] | 17 | * @file debug.h |
---|
[4836] | 18 | * Handles output to console for different Verbose-Modes. |
---|
[3601] | 19 | |
---|
| 20 | There are two main modes HARD and SOFT. HARD is precessed during compileTime where SOFT is for runtime. |
---|
[7161] | 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 |
---|
[4608] | 23 | */ |
---|
[3395] | 24 | |
---|
[3204] | 25 | #ifndef _DEBUG_H |
---|
| 26 | #define _DEBUG_H |
---|
| 27 | |
---|
[3863] | 28 | #include "confincl.h" |
---|
[5944] | 29 | #ifndef NO_SHELL |
---|
| 30 | #include "shell_buffer.h" |
---|
| 31 | #endif /* NO_SHELL */ |
---|
[3590] | 32 | |
---|
| 33 | #include <stdio.h> |
---|
[6868] | 34 | #include <cassert> |
---|
[3590] | 35 | |
---|
| 36 | // DEFINE ERROR MODES |
---|
[3395] | 37 | #define NO 0 |
---|
[3480] | 38 | #define ERR 1 |
---|
| 39 | #define WARN 2 |
---|
| 40 | #define INFO 3 |
---|
[4608] | 41 | //#define DEBUG 4 |
---|
[4373] | 42 | #define vDEBUG 5 |
---|
[3293] | 43 | |
---|
[3592] | 44 | extern int verbose; |
---|
| 45 | |
---|
[3601] | 46 | //definitions |
---|
[3592] | 47 | #ifndef MODULAR_DEBUG |
---|
[5440] | 48 | #define HARD_DEBUG_LEVEL DEBUG |
---|
| 49 | #define SOFT_DEBUG_LEVEL verbose |
---|
[3592] | 50 | #else /* MODULAR_DEBUG */ |
---|
[5440] | 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 */ |
---|
[3601] | 56 | |
---|
[5440] | 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 |
---|
[5300] | 68 | |
---|
[5440] | 69 | // LOADING |
---|
[7169] | 70 | #define DEBUG_MODULE_LOADING 2 |
---|
[5440] | 71 | #define DEBUG_MODULE_IMPORTER 2 |
---|
[3591] | 72 | |
---|
[5440] | 73 | // ENGINES |
---|
| 74 | #define DEBUG_MODULE_GRAPHICS 2 |
---|
[5476] | 75 | #define DEBUG_MODULE_EVENT 2 |
---|
[5440] | 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 |
---|
[5930] | 83 | #define DEBUG_MODULE_SOUND 2 |
---|
[5300] | 84 | |
---|
[5440] | 85 | // MISC |
---|
| 86 | #define DEBUG_MODULE_TRACK_MANAGER 2 |
---|
| 87 | #define DEBUG_MODULE_MATH 2 |
---|
[5300] | 88 | |
---|
[5440] | 89 | #define DEBUG_MODULE_PNODE 2 |
---|
| 90 | #define DEBUG_MODULE_WORLD_ENTITY 2 |
---|
[5300] | 91 | |
---|
[6834] | 92 | #define DEBUG_MODULE_STORY_ENTITY 2 |
---|
[7020] | 93 | #define DEBUG_MODULE_GAME_RULES 2 |
---|
[6834] | 94 | |
---|
[5440] | 95 | #define DEBUG_MODULE_WEAPON 2 |
---|
[3439] | 96 | |
---|
[5440] | 97 | #define HARD_DEBUG_LEVEL DEBUG_SPECIAL_MODULE |
---|
| 98 | |
---|
| 99 | #endif /* DEBUG_SPECIAL_MODULE */ |
---|
[3592] | 100 | #endif /* MODULAR_DEBUG */ |
---|
[4373] | 101 | |
---|
[3293] | 102 | /////////////////////////////////////////////////// |
---|
| 103 | /// PRINTF: prints with filename and linenumber /// |
---|
| 104 | /////////////////////////////////////////////////// |
---|
[4373] | 105 | #define PRINTFNO PRINTF0 |
---|
| 106 | #define PRINTFERR PRINTF1 |
---|
| 107 | #define PRINTFWARN PRINTF2 |
---|
| 108 | #define PRINTFINFO PRINTF3 |
---|
| 109 | #define PRINTFDEBUG PRINTF4 |
---|
| 110 | #define PRINTFVDEBUG PRINTF5 |
---|
[3293] | 111 | |
---|
[5183] | 112 | #if DEBUG <= 3 |
---|
[5076] | 113 | #define PRINTF(x) PRINT(x) |
---|
[5183] | 114 | #endif |
---|
[5822] | 115 | #ifndef NO_SHELL |
---|
[6142] | 116 | #define PRINT_EXEC ShellBuffer::addBufferLineStatic |
---|
[7161] | 117 | #define COUT_EXEC std::cout |
---|
[5822] | 118 | #else /* NO_SHELL */ |
---|
| 119 | #define PRINT_EXEC printf |
---|
[7161] | 120 | #define COUT_EXEC std::cout |
---|
[5822] | 121 | #endif |
---|
[5075] | 122 | |
---|
[5076] | 123 | #ifndef PRINTF |
---|
[3433] | 124 | #ifdef DEBUG |
---|
[3590] | 125 | |
---|
[3205] | 126 | #define PRINTF(x) \ |
---|
| 127 | PRINTF ## x |
---|
| 128 | |
---|
[3592] | 129 | #if HARD_DEBUG_LEVEL >= ERR |
---|
[3205] | 130 | #define PRINTF1 \ |
---|
[3601] | 131 | if (SOFT_DEBUG_LEVEL >= ERR) \ |
---|
[5299] | 132 | printf("(EE)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC |
---|
[4608] | 133 | #else |
---|
[3395] | 134 | #define PRINTF1 if (NO) |
---|
[3205] | 135 | #endif |
---|
[4608] | 136 | |
---|
[3592] | 137 | #if HARD_DEBUG_LEVEL >= WARN |
---|
[3205] | 138 | #define PRINTF2 \ |
---|
[3601] | 139 | if (SOFT_DEBUG_LEVEL >= WARN) \ |
---|
[5299] | 140 | printf("(WW)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC |
---|
[4608] | 141 | |
---|
| 142 | #else |
---|
[3395] | 143 | #define PRINTF2 if (NO) |
---|
[3205] | 144 | #endif |
---|
[4608] | 145 | |
---|
[3592] | 146 | #if HARD_DEBUG_LEVEL >= INFO |
---|
[3205] | 147 | #define PRINTF3 \ |
---|
[3601] | 148 | if (SOFT_DEBUG_LEVEL >= INFO) \ |
---|
[5299] | 149 | printf("(II)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC |
---|
[4608] | 150 | #else |
---|
[3395] | 151 | #define PRINTF3 if (NO) |
---|
[3205] | 152 | #endif |
---|
[4608] | 153 | |
---|
[4373] | 154 | #if HARD_DEBUG_LEVEL >= DEBUG |
---|
[3205] | 155 | #define PRINTF4 \ |
---|
[4373] | 156 | if (SOFT_DEBUG_LEVEL >= DEBUG) \ |
---|
[5299] | 157 | printf("(DD)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC |
---|
[4608] | 158 | #else |
---|
[3395] | 159 | #define PRINTF4 if (NO) |
---|
[3205] | 160 | #endif |
---|
[4608] | 161 | |
---|
[4373] | 162 | #if HARD_DEBUG_LEVEL >= vDEBUG |
---|
[3548] | 163 | #define PRINTF5 \ |
---|
[4373] | 164 | if (SOFT_DEBUG_LEVEL >= vDEBUG) \ |
---|
[5299] | 165 | printf("(VD)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC |
---|
[4608] | 166 | #else |
---|
[3548] | 167 | #define PRINTF5 if (NO) |
---|
| 168 | #endif |
---|
[4608] | 169 | |
---|
| 170 | #else |
---|
[3395] | 171 | #define PRINTF(x) if (NO) |
---|
[3204] | 172 | #endif |
---|
| 173 | |
---|
[3206] | 174 | #define PRINTF0 \ |
---|
[5075] | 175 | printf("%s:%d::", __FILE__, __LINE__) && PRINT_EXEC |
---|
[5076] | 176 | #endif |
---|
[3204] | 177 | |
---|
[3293] | 178 | /////////////////////////////////////////////////// |
---|
| 179 | /// PRINT: just prints output as is /// |
---|
| 180 | /////////////////////////////////////////////////// |
---|
[4373] | 181 | #define PRINTNO PRINT0 |
---|
| 182 | #define PRINTERR PRINT1 |
---|
| 183 | #define PRINTWARN PRINT2 |
---|
| 184 | #define PRINTINFO PRINT3 |
---|
| 185 | #define PRINTDEBUG PRINT4 |
---|
| 186 | #define PRINTVDEBUG PRINT5 |
---|
| 187 | |
---|
[3293] | 188 | #ifdef DEBUG |
---|
| 189 | #define PRINT(x) \ |
---|
[3395] | 190 | PRINT ## x |
---|
[3293] | 191 | |
---|
[3592] | 192 | #if HARD_DEBUG_LEVEL >= ERR |
---|
[4608] | 193 | #define PRINT1 \ |
---|
| 194 | if (SOFT_DEBUG_LEVEL >= ERR) \ |
---|
[5075] | 195 | PRINT_EXEC |
---|
[4608] | 196 | #else |
---|
[3395] | 197 | #define PRINT1 if (NO) |
---|
[3293] | 198 | #endif |
---|
[3395] | 199 | |
---|
[3592] | 200 | #if HARD_DEBUG_LEVEL >= WARN |
---|
[3293] | 201 | #define PRINT2 \ |
---|
[3601] | 202 | if (SOFT_DEBUG_LEVEL >= WARN) \ |
---|
[5075] | 203 | PRINT_EXEC |
---|
[3293] | 204 | |
---|
[4608] | 205 | #else |
---|
[3395] | 206 | #define PRINT2 if (NO) |
---|
[3293] | 207 | #endif |
---|
[3395] | 208 | |
---|
[3592] | 209 | #if HARD_DEBUG_LEVEL >= INFO |
---|
[3293] | 210 | #define PRINT3 \ |
---|
[3601] | 211 | if (SOFT_DEBUG_LEVEL >= INFO) \ |
---|
[5075] | 212 | PRINT_EXEC |
---|
[4608] | 213 | #else |
---|
[3395] | 214 | #define PRINT3 if (NO) |
---|
[3293] | 215 | #endif |
---|
[3395] | 216 | |
---|
[4373] | 217 | #if HARD_DEBUG_LEVEL >= DEBUG |
---|
[3293] | 218 | #define PRINT4 \ |
---|
[4373] | 219 | if (SOFT_DEBUG_LEVEL >= DEBUG) \ |
---|
[5075] | 220 | PRINT_EXEC |
---|
[4608] | 221 | #else |
---|
[3395] | 222 | #define PRINT4 if (NO) |
---|
[3293] | 223 | #endif |
---|
[3395] | 224 | |
---|
[4373] | 225 | #if HARD_DEBUG_LEVEL >= vDEBUG |
---|
[3548] | 226 | #define PRINT5 \ |
---|
[4373] | 227 | if (SOFT_DEBUG_LEVEL >= vDEBUG) \ |
---|
[5299] | 228 | PRINT_EXEC |
---|
[4608] | 229 | #else |
---|
[3548] | 230 | #define PRINT5 if (NO) |
---|
| 231 | #endif |
---|
[3395] | 232 | |
---|
[3548] | 233 | |
---|
[4608] | 234 | #else |
---|
[3395] | 235 | #define PRINT(x) if (NO) |
---|
[3293] | 236 | #endif |
---|
| 237 | |
---|
| 238 | #define PRINT0 \ |
---|
[5075] | 239 | PRINT_EXEC |
---|
[3293] | 240 | |
---|
[7161] | 241 | |
---|
| 242 | |
---|
| 243 | //////////////////////////////////////////////////////// |
---|
| 244 | /// COUT: just prints output as is with std::cout /// |
---|
| 245 | //////////////////////////////////////////////////////// |
---|
| 246 | #define COUTNO COUT0 |
---|
| 247 | #define COUTERR COUT1 |
---|
| 248 | #define COUTWARN COUT2 |
---|
| 249 | #define COUTINFO COUT3 |
---|
| 250 | #define COUTDEBUG COUT4 |
---|
| 251 | #define COUTVDEBUG COUT5 |
---|
| 252 | |
---|
| 253 | #ifdef DEBUG |
---|
| 254 | #define COUT(x) \ |
---|
| 255 | COUT ## x |
---|
| 256 | |
---|
| 257 | #if HARD_DEBUG_LEVEL >= ERR |
---|
| 258 | #define COUT1 \ |
---|
| 259 | if (SOFT_DEBUG_LEVEL >= ERR) \ |
---|
| 260 | COUT_EXEC |
---|
| 261 | #else |
---|
| 262 | #define COUT1 if (NO)\ |
---|
| 263 | COUT_EXEC |
---|
| 264 | #endif |
---|
| 265 | |
---|
| 266 | #if HARD_DEBUG_LEVEL >= WARN |
---|
| 267 | #define COUT2 \ |
---|
| 268 | if (SOFT_DEBUG_LEVEL >= WARN) \ |
---|
| 269 | COUT_EXEC |
---|
| 270 | |
---|
| 271 | #else |
---|
| 272 | #define COUT2 if (NO) \ |
---|
| 273 | COUT_EXEC |
---|
| 274 | #endif |
---|
| 275 | |
---|
| 276 | #if HARD_DEBUG_LEVEL >= INFO |
---|
| 277 | #define COUT3 \ |
---|
| 278 | if (SOFT_DEBUG_LEVEL >= INFO) \ |
---|
| 279 | COUT_EXEC |
---|
| 280 | #else |
---|
| 281 | #define COUT3 if (NO) \ |
---|
| 282 | COUT_EXEC |
---|
| 283 | #endif |
---|
| 284 | |
---|
| 285 | #if HARD_DEBUG_LEVEL >= DEBUG |
---|
| 286 | #define COUT4 \ |
---|
| 287 | if (SOFT_DEBUG_LEVEL >= DEBUG) \ |
---|
| 288 | COUT_EXEC |
---|
| 289 | #else |
---|
| 290 | #define COUT4 if (NO) \ |
---|
| 291 | COUT_EXEC |
---|
| 292 | #endif |
---|
| 293 | |
---|
| 294 | #if HARD_DEBUG_LEVEL >= vDEBUG |
---|
| 295 | #define COUT5 \ |
---|
| 296 | if (SOFT_DEBUG_LEVEL >= vDEBUG) \ |
---|
| 297 | COUT_EXEC |
---|
| 298 | #else |
---|
| 299 | #define COUT5 if (NO) \ |
---|
| 300 | COUT_EXEC |
---|
| 301 | #endif |
---|
| 302 | |
---|
| 303 | |
---|
| 304 | #else |
---|
| 305 | #define COUT(x) if (NO) \ |
---|
| 306 | COUT_EXEC |
---|
| 307 | #endif |
---|
| 308 | |
---|
| 309 | #define COUT0 \ |
---|
| 310 | COUT_EXEC |
---|
| 311 | |
---|
| 312 | |
---|
[3204] | 313 | #endif /* _DEBUG_H */ |
---|