[3395] | 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. |
---|
[3601] | 19 | |
---|
| 20 | There are two main modes HARD and SOFT. HARD is precessed during compileTime where SOFT is for runtime. |
---|
[3863] | 21 | \li HARD: One can choose between different modes. see: // DEFINE_MODULES |
---|
[3601] | 22 | \li SOFT: If you want each module can have its own variable for processing. just pass it to DEBUG_MODULE_SOFT |
---|
[3395] | 23 | */ |
---|
| 24 | |
---|
[3204] | 25 | #ifndef _DEBUG_H |
---|
| 26 | #define _DEBUG_H |
---|
| 27 | |
---|
[3863] | 28 | #include "confincl.h" |
---|
[3590] | 29 | |
---|
| 30 | #include <stdio.h> |
---|
| 31 | |
---|
| 32 | // DEFINE ERROR MODES |
---|
[3395] | 33 | #define NO 0 |
---|
[3480] | 34 | #define ERR 1 |
---|
| 35 | #define WARN 2 |
---|
| 36 | #define INFO 3 |
---|
[3395] | 37 | #define DEBUGING 4 |
---|
[3548] | 38 | #define vDEBUGING 5 |
---|
[3293] | 39 | |
---|
[3592] | 40 | extern int verbose; |
---|
| 41 | |
---|
[3601] | 42 | //definitions |
---|
[3592] | 43 | #ifndef MODULAR_DEBUG |
---|
| 44 | #define HARD_DEBUG_LEVEL DEBUG |
---|
[3601] | 45 | #define SOFT_DEBUG_LEVEL verbose |
---|
[3592] | 46 | #else /* MODULAR_DEBUG */ |
---|
[3601] | 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 | |
---|
[3590] | 53 | #ifndef DEBUG_SPECIAL_MODULE |
---|
[3592] | 54 | #define HARD_DEBUG_LEVEL DEBUG |
---|
| 55 | #else /* DEBUG_SPECIAL_MODULE */ |
---|
[3863] | 56 | // DEFINE MODULES |
---|
[3655] | 57 | #define DEBUG_MODULE_ORXONOX 0 |
---|
[4301] | 58 | #define DEBUG_MODULE_WORLD 0 |
---|
| 59 | #define DEBUG_MODULE_PNODE 0 |
---|
[3655] | 60 | #define DEBUG_MODULE_WORLD_ENTITY 0 |
---|
[4301] | 61 | #define DEBUG_MODULE_COMMAND_NODE 0 |
---|
[3655] | 62 | #define DEBUG_MODULE_GRAPHICS 0 |
---|
[4178] | 63 | #define DEBUG_MODULE_LOAD 2 |
---|
[3591] | 64 | |
---|
[4301] | 65 | #define DEBUG_MODULE_IMPORTER 0 |
---|
[3655] | 66 | #define DEBUG_MODULE_TRACK_MANAGER 0 |
---|
[3688] | 67 | #define DEBUG_MODULE_GARBAGE_COLLECTOR 0 |
---|
[4301] | 68 | #define DEBUG_MODULE_OBJECT_MANAGER 3 |
---|
[3655] | 69 | #define DEBUG_MODULE_LIGHT 0 |
---|
[3752] | 70 | #define DEBUG_MODULE_PLAYER 1 |
---|
[4301] | 71 | #define DEBUG_MODULE_WEAPON 0 |
---|
[3655] | 72 | #define DEBUG_MODULE_MATH 0 |
---|
[3953] | 73 | #define DEBUG_MODULE_FONT 1 |
---|
| 74 | #define DEBUG_MODULE_ANIM 1 |
---|
[4301] | 75 | #define DEBUG_MODULE_PARTICLE 1 |
---|
[3439] | 76 | |
---|
[3655] | 77 | #define DEBUG_MODULE_NULL_PARENT 0 |
---|
[3591] | 78 | |
---|
[3395] | 79 | |
---|
[3592] | 80 | #define HARD_DEBUG_LEVEL DEBUG_SPECIAL_MODULE |
---|
| 81 | #endif /* DEBUG_SPECIAL_MODULE */ |
---|
| 82 | #endif /* MODULAR_DEBUG */ |
---|
[3293] | 83 | /////////////////////////////////////////////////// |
---|
| 84 | /// PRINTF: prints with filename and linenumber /// |
---|
| 85 | /////////////////////////////////////////////////// |
---|
| 86 | |
---|
[3433] | 87 | #ifdef DEBUG |
---|
[3590] | 88 | |
---|
[3205] | 89 | #define PRINTF(x) \ |
---|
| 90 | PRINTF ## x |
---|
| 91 | |
---|
[3592] | 92 | #if HARD_DEBUG_LEVEL >= ERR |
---|
[3205] | 93 | #define PRINTF1 \ |
---|
[3601] | 94 | if (SOFT_DEBUG_LEVEL >= ERR) \ |
---|
[3511] | 95 | printf("ERROR::%s:%d:", __FILE__, __LINE__) && printf |
---|
[3205] | 96 | #else |
---|
[3395] | 97 | #define PRINTF1 if (NO) |
---|
[3205] | 98 | #endif |
---|
| 99 | |
---|
[3592] | 100 | #if HARD_DEBUG_LEVEL >= WARN |
---|
[3205] | 101 | #define PRINTF2 \ |
---|
[3601] | 102 | if (SOFT_DEBUG_LEVEL >= WARN) \ |
---|
[3511] | 103 | printf("WARNING::%s:%d:", __FILE__, __LINE__) && printf |
---|
[3206] | 104 | |
---|
[3205] | 105 | #else |
---|
[3395] | 106 | #define PRINTF2 if (NO) |
---|
[3205] | 107 | #endif |
---|
| 108 | |
---|
[3592] | 109 | #if HARD_DEBUG_LEVEL >= INFO |
---|
[3205] | 110 | #define PRINTF3 \ |
---|
[3601] | 111 | if (SOFT_DEBUG_LEVEL >= INFO) \ |
---|
[3511] | 112 | printf("INFO::%s:%d:", __FILE__, __LINE__) && printf |
---|
[3205] | 113 | #else |
---|
[3395] | 114 | #define PRINTF3 if (NO) |
---|
[3205] | 115 | #endif |
---|
| 116 | |
---|
[3592] | 117 | #if HARD_DEBUG_LEVEL >= DEBUGING |
---|
[3205] | 118 | #define PRINTF4 \ |
---|
[3601] | 119 | if (SOFT_DEBUG_LEVEL >= DEBUGING) \ |
---|
[3511] | 120 | printf("DEBUG::%s:%d:", __FILE__, __LINE__) && printf |
---|
[3205] | 121 | #else |
---|
[3395] | 122 | #define PRINTF4 if (NO) |
---|
[3205] | 123 | #endif |
---|
| 124 | |
---|
[3592] | 125 | #if HARD_DEBUG_LEVEL >= vDEBUGING |
---|
[3548] | 126 | #define PRINTF5 \ |
---|
[3601] | 127 | if (SOFT_DEBUG_LEVEL >= vDEBUGING) \ |
---|
[3548] | 128 | printf("VERYDEBUG::%s:%d:", __FILE__, __LINE__) && printf |
---|
| 129 | #else |
---|
| 130 | #define PRINTF5 if (NO) |
---|
| 131 | #endif |
---|
| 132 | |
---|
[3204] | 133 | #else |
---|
[3395] | 134 | #define PRINTF(x) if (NO) |
---|
[3204] | 135 | #endif |
---|
| 136 | |
---|
[3206] | 137 | #define PRINTF0 \ |
---|
[3212] | 138 | printf("%s:%d::", __FILE__, __LINE__) && printf |
---|
[3204] | 139 | |
---|
[3293] | 140 | |
---|
| 141 | /////////////////////////////////////////////////// |
---|
| 142 | /// PRINT: just prints output as is /// |
---|
| 143 | /////////////////////////////////////////////////// |
---|
| 144 | #ifdef DEBUG |
---|
| 145 | #define PRINT(x) \ |
---|
[3395] | 146 | PRINT ## x |
---|
[3293] | 147 | |
---|
[3592] | 148 | #if HARD_DEBUG_LEVEL >= ERR |
---|
[3395] | 149 | #define PRINT1 \ |
---|
[3601] | 150 | if (SOFT_DEBUG_LEVEL >= ERR) \ |
---|
[3395] | 151 | printf |
---|
[3293] | 152 | #else |
---|
[3395] | 153 | #define PRINT1 if (NO) |
---|
[3293] | 154 | #endif |
---|
[3395] | 155 | |
---|
[3592] | 156 | #if HARD_DEBUG_LEVEL >= WARN |
---|
[3293] | 157 | #define PRINT2 \ |
---|
[3601] | 158 | if (SOFT_DEBUG_LEVEL >= WARN) \ |
---|
[3395] | 159 | printf |
---|
[3293] | 160 | |
---|
| 161 | #else |
---|
[3395] | 162 | #define PRINT2 if (NO) |
---|
[3293] | 163 | #endif |
---|
[3395] | 164 | |
---|
[3592] | 165 | #if HARD_DEBUG_LEVEL >= INFO |
---|
[3293] | 166 | #define PRINT3 \ |
---|
[3601] | 167 | if (SOFT_DEBUG_LEVEL >= INFO) \ |
---|
[3395] | 168 | printf |
---|
| 169 | #else |
---|
| 170 | #define PRINT3 if (NO) |
---|
[3293] | 171 | #endif |
---|
[3395] | 172 | |
---|
[3592] | 173 | #if HARD_DEBUG_LEVEL >= DEBUGING |
---|
[3293] | 174 | #define PRINT4 \ |
---|
[3601] | 175 | if (SOFT_DEBUG_LEVEL >= DEBUGING) \ |
---|
[3395] | 176 | printf |
---|
[3293] | 177 | #else |
---|
[3395] | 178 | #define PRINT4 if (NO) |
---|
[3293] | 179 | #endif |
---|
[3395] | 180 | |
---|
[3592] | 181 | #if HARD_DEBUG_LEVEL >= vDEBUGING |
---|
[3548] | 182 | #define PRINT5 \ |
---|
[3601] | 183 | if (SOFT_DEBUG_LEVEL >= vDEBUGING) \ |
---|
[3548] | 184 | printf("VERYDEBUG::%s:%d:", __FILE__, __LINE__) && printf |
---|
| 185 | #else |
---|
| 186 | #define PRINT5 if (NO) |
---|
| 187 | #endif |
---|
[3395] | 188 | |
---|
[3548] | 189 | |
---|
[3293] | 190 | #else |
---|
[3395] | 191 | #define PRINT(x) if (NO) |
---|
[3293] | 192 | #endif |
---|
| 193 | |
---|
| 194 | #define PRINT0 \ |
---|
[3395] | 195 | printf |
---|
[3293] | 196 | |
---|
| 197 | /////////////////////////////////////////////////// |
---|
| 198 | /// COUT: simple cout print with verbose-check /// |
---|
| 199 | /////////////////////////////////////////////////// |
---|
| 200 | #ifdef DEBUG |
---|
| 201 | #define COUT(x) \ |
---|
| 202 | COUT ## x |
---|
| 203 | |
---|
[3592] | 204 | #if HARD_DEBUG_LEVEL >= 1 |
---|
[3293] | 205 | #define COUT1 \ |
---|
[3601] | 206 | if (SOFT_DEBUG_LEVEL >= 1 ) \ |
---|
[3293] | 207 | cout |
---|
| 208 | #else |
---|
[3395] | 209 | #define COUT1 if (NO) cout |
---|
[3293] | 210 | #endif |
---|
| 211 | |
---|
[3592] | 212 | #if HARD_DEBUG_LEVEL >= 2 |
---|
[3293] | 213 | #define COUT2 \ |
---|
[3601] | 214 | if (SOFT_DEBUG_LEVEL >= 2 ) \ |
---|
[3293] | 215 | cout |
---|
| 216 | |
---|
| 217 | #else |
---|
[3395] | 218 | #define COUT2 if (NO) cout |
---|
[3293] | 219 | #endif |
---|
| 220 | |
---|
[3592] | 221 | #if HARD_DEBUG_LEVEL >= 3 |
---|
[3293] | 222 | #define COUT3 \ |
---|
[3601] | 223 | if (SOFT_DEBUG_LEVEL >= 3 ) \ |
---|
[3293] | 224 | cout |
---|
| 225 | #else |
---|
[3395] | 226 | #define COUT3 if (NO) cout |
---|
[3293] | 227 | #endif |
---|
| 228 | |
---|
[3592] | 229 | #if HARD_DEBUG_LEVEL >= 4 |
---|
[3293] | 230 | #define COUT4 \ |
---|
[3601] | 231 | if (SOFT_DEBUG_LEVEL >= 4 ) \ |
---|
[3293] | 232 | cout |
---|
| 233 | #else |
---|
[3395] | 234 | #define COUT4 if (NO) cout |
---|
[3293] | 235 | #endif |
---|
| 236 | |
---|
| 237 | |
---|
| 238 | #else |
---|
[3395] | 239 | #define COUT(x) if (NO) cout |
---|
[3293] | 240 | #endif |
---|
| 241 | |
---|
| 242 | #define COUT0 \ |
---|
| 243 | cout |
---|
| 244 | |
---|
[3204] | 245 | #endif /* _DEBUG_H */ |
---|