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