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