[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 |
---|
[4373] | 37 | #define DEBUG 4 |
---|
| 38 | #define vDEBUG 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 |
---|
[4287] | 58 | #define DEBUG_MODULE_WORLD 0 |
---|
| 59 | #define DEBUG_MODULE_PNODE 0 |
---|
[3655] | 60 | #define DEBUG_MODULE_WORLD_ENTITY 0 |
---|
[4287] | 61 | #define DEBUG_MODULE_COMMAND_NODE 0 |
---|
[3655] | 62 | #define DEBUG_MODULE_GRAPHICS 0 |
---|
[4094] | 63 | #define DEBUG_MODULE_LOAD 2 |
---|
[3591] | 64 | |
---|
[4287] | 65 | #define DEBUG_MODULE_IMPORTER 0 |
---|
[3655] | 66 | #define DEBUG_MODULE_TRACK_MANAGER 0 |
---|
[3688] | 67 | #define DEBUG_MODULE_GARBAGE_COLLECTOR 0 |
---|
[4389] | 68 | #define DEBUG_MODULE_OBJECT_MANAGER 0 |
---|
[3655] | 69 | #define DEBUG_MODULE_LIGHT 0 |
---|
[3752] | 70 | #define DEBUG_MODULE_PLAYER 1 |
---|
[4287] | 71 | #define DEBUG_MODULE_WEAPON 0 |
---|
[3655] | 72 | #define DEBUG_MODULE_MATH 0 |
---|
[3875] | 73 | #define DEBUG_MODULE_FONT 1 |
---|
| 74 | #define DEBUG_MODULE_ANIM 1 |
---|
[4287] | 75 | #define DEBUG_MODULE_PARTICLE 1 |
---|
[4381] | 76 | #define DEBUG_MODULE_PHYSICS 1 |
---|
[4354] | 77 | #define DEBUG_MODULE_EVENT 3 |
---|
[3439] | 78 | |
---|
[3655] | 79 | #define DEBUG_MODULE_NULL_PARENT 0 |
---|
[4471] | 80 | #define DEBUG_MODULE_NETWORK 0 |
---|
[3591] | 81 | |
---|
[3395] | 82 | |
---|
[3592] | 83 | #define HARD_DEBUG_LEVEL DEBUG_SPECIAL_MODULE |
---|
| 84 | #endif /* DEBUG_SPECIAL_MODULE */ |
---|
| 85 | #endif /* MODULAR_DEBUG */ |
---|
[4373] | 86 | |
---|
[3293] | 87 | /////////////////////////////////////////////////// |
---|
| 88 | /// PRINTF: prints with filename and linenumber /// |
---|
| 89 | /////////////////////////////////////////////////// |
---|
[4373] | 90 | #define PRINTFNO PRINTF0 |
---|
| 91 | #define PRINTFERR PRINTF1 |
---|
| 92 | #define PRINTFWARN PRINTF2 |
---|
| 93 | #define PRINTFINFO PRINTF3 |
---|
| 94 | #define PRINTFDEBUG PRINTF4 |
---|
| 95 | #define PRINTFVDEBUG PRINTF5 |
---|
[3293] | 96 | |
---|
[3433] | 97 | #ifdef DEBUG |
---|
[3590] | 98 | |
---|
[3205] | 99 | #define PRINTF(x) \ |
---|
| 100 | PRINTF ## x |
---|
| 101 | |
---|
[3592] | 102 | #if HARD_DEBUG_LEVEL >= ERR |
---|
[3205] | 103 | #define PRINTF1 \ |
---|
[3601] | 104 | if (SOFT_DEBUG_LEVEL >= ERR) \ |
---|
[3511] | 105 | printf("ERROR::%s:%d:", __FILE__, __LINE__) && printf |
---|
[3205] | 106 | #else |
---|
[3395] | 107 | #define PRINTF1 if (NO) |
---|
[3205] | 108 | #endif |
---|
| 109 | |
---|
[3592] | 110 | #if HARD_DEBUG_LEVEL >= WARN |
---|
[3205] | 111 | #define PRINTF2 \ |
---|
[3601] | 112 | if (SOFT_DEBUG_LEVEL >= WARN) \ |
---|
[3511] | 113 | printf("WARNING::%s:%d:", __FILE__, __LINE__) && printf |
---|
[3206] | 114 | |
---|
[3205] | 115 | #else |
---|
[3395] | 116 | #define PRINTF2 if (NO) |
---|
[3205] | 117 | #endif |
---|
| 118 | |
---|
[3592] | 119 | #if HARD_DEBUG_LEVEL >= INFO |
---|
[3205] | 120 | #define PRINTF3 \ |
---|
[3601] | 121 | if (SOFT_DEBUG_LEVEL >= INFO) \ |
---|
[3511] | 122 | printf("INFO::%s:%d:", __FILE__, __LINE__) && printf |
---|
[3205] | 123 | #else |
---|
[3395] | 124 | #define PRINTF3 if (NO) |
---|
[3205] | 125 | #endif |
---|
| 126 | |
---|
[4373] | 127 | #if HARD_DEBUG_LEVEL >= DEBUG |
---|
[3205] | 128 | #define PRINTF4 \ |
---|
[4373] | 129 | if (SOFT_DEBUG_LEVEL >= DEBUG) \ |
---|
[3511] | 130 | printf("DEBUG::%s:%d:", __FILE__, __LINE__) && printf |
---|
[3205] | 131 | #else |
---|
[3395] | 132 | #define PRINTF4 if (NO) |
---|
[3205] | 133 | #endif |
---|
| 134 | |
---|
[4373] | 135 | #if HARD_DEBUG_LEVEL >= vDEBUG |
---|
[3548] | 136 | #define PRINTF5 \ |
---|
[4373] | 137 | if (SOFT_DEBUG_LEVEL >= vDEBUG) \ |
---|
[3548] | 138 | printf("VERYDEBUG::%s:%d:", __FILE__, __LINE__) && printf |
---|
| 139 | #else |
---|
| 140 | #define PRINTF5 if (NO) |
---|
| 141 | #endif |
---|
| 142 | |
---|
[3204] | 143 | #else |
---|
[3395] | 144 | #define PRINTF(x) if (NO) |
---|
[3204] | 145 | #endif |
---|
| 146 | |
---|
[3206] | 147 | #define PRINTF0 \ |
---|
[3212] | 148 | printf("%s:%d::", __FILE__, __LINE__) && printf |
---|
[3204] | 149 | |
---|
[3293] | 150 | |
---|
| 151 | /////////////////////////////////////////////////// |
---|
| 152 | /// PRINT: just prints output as is /// |
---|
| 153 | /////////////////////////////////////////////////// |
---|
[4373] | 154 | #define PRINTNO PRINT0 |
---|
| 155 | #define PRINTERR PRINT1 |
---|
| 156 | #define PRINTWARN PRINT2 |
---|
| 157 | #define PRINTINFO PRINT3 |
---|
| 158 | #define PRINTDEBUG PRINT4 |
---|
| 159 | #define PRINTVDEBUG PRINT5 |
---|
| 160 | |
---|
[3293] | 161 | #ifdef DEBUG |
---|
| 162 | #define PRINT(x) \ |
---|
[3395] | 163 | PRINT ## x |
---|
[3293] | 164 | |
---|
[3592] | 165 | #if HARD_DEBUG_LEVEL >= ERR |
---|
[3395] | 166 | #define PRINT1 \ |
---|
[3601] | 167 | if (SOFT_DEBUG_LEVEL >= ERR) \ |
---|
[3395] | 168 | printf |
---|
[3293] | 169 | #else |
---|
[3395] | 170 | #define PRINT1 if (NO) |
---|
[3293] | 171 | #endif |
---|
[3395] | 172 | |
---|
[3592] | 173 | #if HARD_DEBUG_LEVEL >= WARN |
---|
[3293] | 174 | #define PRINT2 \ |
---|
[3601] | 175 | if (SOFT_DEBUG_LEVEL >= WARN) \ |
---|
[3395] | 176 | printf |
---|
[3293] | 177 | |
---|
| 178 | #else |
---|
[3395] | 179 | #define PRINT2 if (NO) |
---|
[3293] | 180 | #endif |
---|
[3395] | 181 | |
---|
[3592] | 182 | #if HARD_DEBUG_LEVEL >= INFO |
---|
[3293] | 183 | #define PRINT3 \ |
---|
[3601] | 184 | if (SOFT_DEBUG_LEVEL >= INFO) \ |
---|
[3395] | 185 | printf |
---|
| 186 | #else |
---|
| 187 | #define PRINT3 if (NO) |
---|
[3293] | 188 | #endif |
---|
[3395] | 189 | |
---|
[4373] | 190 | #if HARD_DEBUG_LEVEL >= DEBUG |
---|
[3293] | 191 | #define PRINT4 \ |
---|
[4373] | 192 | if (SOFT_DEBUG_LEVEL >= DEBUG) \ |
---|
[3395] | 193 | printf |
---|
[3293] | 194 | #else |
---|
[3395] | 195 | #define PRINT4 if (NO) |
---|
[3293] | 196 | #endif |
---|
[3395] | 197 | |
---|
[4373] | 198 | #if HARD_DEBUG_LEVEL >= vDEBUG |
---|
[3548] | 199 | #define PRINT5 \ |
---|
[4373] | 200 | if (SOFT_DEBUG_LEVEL >= vDEBUG) \ |
---|
[3548] | 201 | printf("VERYDEBUG::%s:%d:", __FILE__, __LINE__) && printf |
---|
| 202 | #else |
---|
| 203 | #define PRINT5 if (NO) |
---|
| 204 | #endif |
---|
[3395] | 205 | |
---|
[3548] | 206 | |
---|
[3293] | 207 | #else |
---|
[3395] | 208 | #define PRINT(x) if (NO) |
---|
[3293] | 209 | #endif |
---|
| 210 | |
---|
| 211 | #define PRINT0 \ |
---|
[3395] | 212 | printf |
---|
[3293] | 213 | |
---|
[3204] | 214 | #endif /* _DEBUG_H */ |
---|