[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. |
---|
[4608] | 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 |
---|
[4608] | 23 | */ |
---|
[3395] | 24 | |
---|
[3204] | 25 | #ifndef _DEBUG_H |
---|
| 26 | #define _DEBUG_H |
---|
| 27 | |
---|
[3863] | 28 | #include "confincl.h" |
---|
[5174] | 29 | #include "shell_buffer.h" |
---|
[3590] | 30 | |
---|
| 31 | #include <stdio.h> |
---|
| 32 | |
---|
| 33 | // DEFINE ERROR MODES |
---|
[3395] | 34 | #define NO 0 |
---|
[3480] | 35 | #define ERR 1 |
---|
| 36 | #define WARN 2 |
---|
| 37 | #define INFO 3 |
---|
[4608] | 38 | //#define DEBUG 4 |
---|
[4373] | 39 | #define vDEBUG 5 |
---|
[3293] | 40 | |
---|
[3592] | 41 | extern int verbose; |
---|
| 42 | |
---|
[3601] | 43 | //definitions |
---|
[3592] | 44 | #ifndef MODULAR_DEBUG |
---|
| 45 | #define HARD_DEBUG_LEVEL DEBUG |
---|
[3601] | 46 | #define SOFT_DEBUG_LEVEL verbose |
---|
[3592] | 47 | #else /* MODULAR_DEBUG */ |
---|
[4608] | 48 | #ifndef DEBUG_MODULE_SOFT |
---|
[3601] | 49 | #define SOFT_DEBUG_LEVEL verbose |
---|
| 50 | #else /* DEBUG_MODULE_SOFT */ |
---|
| 51 | #define SOFT_DEBUG_LEVEL DEBUG_MODULE_SOFT |
---|
| 52 | #endif /* DEBUG_MODULE_SOFT */ |
---|
| 53 | |
---|
[3590] | 54 | #ifndef DEBUG_SPECIAL_MODULE |
---|
[3592] | 55 | #define HARD_DEBUG_LEVEL DEBUG |
---|
| 56 | #else /* DEBUG_SPECIAL_MODULE */ |
---|
[3863] | 57 | // DEFINE MODULES |
---|
[5048] | 58 | #define DEBUG_MODULE_ORXONOX 2 |
---|
| 59 | #define DEBUG_MODULE_WORLD 2 |
---|
| 60 | #define DEBUG_MODULE_PNODE 2 |
---|
| 61 | #define DEBUG_MODULE_WORLD_ENTITY 2 |
---|
| 62 | #define DEBUG_MODULE_COMMAND_NODE 2 |
---|
| 63 | #define DEBUG_MODULE_GRAPHICS 2 |
---|
[4094] | 64 | #define DEBUG_MODULE_LOAD 2 |
---|
[3591] | 65 | |
---|
[5048] | 66 | #define DEBUG_MODULE_IMPORTER 2 |
---|
[4620] | 67 | #define DEBUG_MODULE_TRACK_MANAGER 2 |
---|
[5048] | 68 | #define DEBUG_MODULE_GARBAGE_COLLECTOR 2 |
---|
[4932] | 69 | #define DEBUG_MODULE_OBJECT_MANAGER 2 |
---|
[5048] | 70 | #define DEBUG_MODULE_LIGHT 2 |
---|
| 71 | #define DEBUG_MODULE_PLAYER 2 |
---|
| 72 | #define DEBUG_MODULE_WEAPON 2 |
---|
| 73 | #define DEBUG_MODULE_MATH 2 |
---|
| 74 | #define DEBUG_MODULE_FONT 2 |
---|
| 75 | #define DEBUG_MODULE_ANIM 2 |
---|
| 76 | #define DEBUG_MODULE_PARTICLE 2 |
---|
| 77 | #define DEBUG_MODULE_PHYSICS 2 |
---|
| 78 | #define DEBUG_MODULE_EVENT 2 |
---|
[3439] | 79 | |
---|
[5048] | 80 | #define DEBUG_MODULE_NULL_PARENT 2 |
---|
| 81 | #define DEBUG_MODULE_NETWORK 2 |
---|
[3591] | 82 | |
---|
[5048] | 83 | #define DEBUG_MODULE_COLLISON_DETECTION 2 |
---|
| 84 | #define DEBUG_MODULE_SPATIAL_SEPARATION 2 |
---|
[3395] | 85 | |
---|
[3592] | 86 | #define HARD_DEBUG_LEVEL DEBUG_SPECIAL_MODULE |
---|
| 87 | #endif /* DEBUG_SPECIAL_MODULE */ |
---|
| 88 | #endif /* MODULAR_DEBUG */ |
---|
[4373] | 89 | |
---|
[3293] | 90 | /////////////////////////////////////////////////// |
---|
| 91 | /// PRINTF: prints with filename and linenumber /// |
---|
| 92 | /////////////////////////////////////////////////// |
---|
[4373] | 93 | #define PRINTFNO PRINTF0 |
---|
| 94 | #define PRINTFERR PRINTF1 |
---|
| 95 | #define PRINTFWARN PRINTF2 |
---|
| 96 | #define PRINTFINFO PRINTF3 |
---|
| 97 | #define PRINTFDEBUG PRINTF4 |
---|
| 98 | #define PRINTFVDEBUG PRINTF5 |
---|
[3293] | 99 | |
---|
[5183] | 100 | #if DEBUG <= 3 |
---|
[5076] | 101 | #define PRINTF(x) PRINT(x) |
---|
[5183] | 102 | #endif |
---|
[5174] | 103 | #define PRINT_EXEC ShellBuffer::addBufferLineStatic |
---|
[5075] | 104 | |
---|
[5076] | 105 | #ifndef PRINTF |
---|
[3433] | 106 | #ifdef DEBUG |
---|
[3590] | 107 | |
---|
[3205] | 108 | #define PRINTF(x) \ |
---|
| 109 | PRINTF ## x |
---|
| 110 | |
---|
[3592] | 111 | #if HARD_DEBUG_LEVEL >= ERR |
---|
[3205] | 112 | #define PRINTF1 \ |
---|
[3601] | 113 | if (SOFT_DEBUG_LEVEL >= ERR) \ |
---|
[5075] | 114 | printf("ERROR::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC |
---|
[4608] | 115 | #else |
---|
[3395] | 116 | #define PRINTF1 if (NO) |
---|
[3205] | 117 | #endif |
---|
[4608] | 118 | |
---|
[3592] | 119 | #if HARD_DEBUG_LEVEL >= WARN |
---|
[3205] | 120 | #define PRINTF2 \ |
---|
[3601] | 121 | if (SOFT_DEBUG_LEVEL >= WARN) \ |
---|
[5075] | 122 | printf("WARNING::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC |
---|
[4608] | 123 | |
---|
| 124 | #else |
---|
[3395] | 125 | #define PRINTF2 if (NO) |
---|
[3205] | 126 | #endif |
---|
[4608] | 127 | |
---|
[3592] | 128 | #if HARD_DEBUG_LEVEL >= INFO |
---|
[3205] | 129 | #define PRINTF3 \ |
---|
[3601] | 130 | if (SOFT_DEBUG_LEVEL >= INFO) \ |
---|
[5075] | 131 | printf("INFO::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC |
---|
[4608] | 132 | #else |
---|
[3395] | 133 | #define PRINTF3 if (NO) |
---|
[3205] | 134 | #endif |
---|
[4608] | 135 | |
---|
[4373] | 136 | #if HARD_DEBUG_LEVEL >= DEBUG |
---|
[3205] | 137 | #define PRINTF4 \ |
---|
[4373] | 138 | if (SOFT_DEBUG_LEVEL >= DEBUG) \ |
---|
[5075] | 139 | printf("DEBUG::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC |
---|
[4608] | 140 | #else |
---|
[3395] | 141 | #define PRINTF4 if (NO) |
---|
[3205] | 142 | #endif |
---|
[4608] | 143 | |
---|
[4373] | 144 | #if HARD_DEBUG_LEVEL >= vDEBUG |
---|
[3548] | 145 | #define PRINTF5 \ |
---|
[4373] | 146 | if (SOFT_DEBUG_LEVEL >= vDEBUG) \ |
---|
[5075] | 147 | printf("VERYDEBUG::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC |
---|
[4608] | 148 | #else |
---|
[3548] | 149 | #define PRINTF5 if (NO) |
---|
| 150 | #endif |
---|
[4608] | 151 | |
---|
| 152 | #else |
---|
[3395] | 153 | #define PRINTF(x) if (NO) |
---|
[3204] | 154 | #endif |
---|
| 155 | |
---|
[3206] | 156 | #define PRINTF0 \ |
---|
[5075] | 157 | printf("%s:%d::", __FILE__, __LINE__) && PRINT_EXEC |
---|
[5076] | 158 | #endif |
---|
[3204] | 159 | |
---|
[3293] | 160 | /////////////////////////////////////////////////// |
---|
| 161 | /// PRINT: just prints output as is /// |
---|
| 162 | /////////////////////////////////////////////////// |
---|
[4373] | 163 | #define PRINTNO PRINT0 |
---|
| 164 | #define PRINTERR PRINT1 |
---|
| 165 | #define PRINTWARN PRINT2 |
---|
| 166 | #define PRINTINFO PRINT3 |
---|
| 167 | #define PRINTDEBUG PRINT4 |
---|
| 168 | #define PRINTVDEBUG PRINT5 |
---|
| 169 | |
---|
[3293] | 170 | #ifdef DEBUG |
---|
| 171 | #define PRINT(x) \ |
---|
[3395] | 172 | PRINT ## x |
---|
[3293] | 173 | |
---|
[3592] | 174 | #if HARD_DEBUG_LEVEL >= ERR |
---|
[4608] | 175 | #define PRINT1 \ |
---|
| 176 | if (SOFT_DEBUG_LEVEL >= ERR) \ |
---|
[5075] | 177 | PRINT_EXEC |
---|
[4608] | 178 | #else |
---|
[3395] | 179 | #define PRINT1 if (NO) |
---|
[3293] | 180 | #endif |
---|
[3395] | 181 | |
---|
[3592] | 182 | #if HARD_DEBUG_LEVEL >= WARN |
---|
[3293] | 183 | #define PRINT2 \ |
---|
[3601] | 184 | if (SOFT_DEBUG_LEVEL >= WARN) \ |
---|
[5075] | 185 | PRINT_EXEC |
---|
[3293] | 186 | |
---|
[4608] | 187 | #else |
---|
[3395] | 188 | #define PRINT2 if (NO) |
---|
[3293] | 189 | #endif |
---|
[3395] | 190 | |
---|
[3592] | 191 | #if HARD_DEBUG_LEVEL >= INFO |
---|
[3293] | 192 | #define PRINT3 \ |
---|
[3601] | 193 | if (SOFT_DEBUG_LEVEL >= INFO) \ |
---|
[5075] | 194 | PRINT_EXEC |
---|
[4608] | 195 | #else |
---|
[3395] | 196 | #define PRINT3 if (NO) |
---|
[3293] | 197 | #endif |
---|
[3395] | 198 | |
---|
[4373] | 199 | #if HARD_DEBUG_LEVEL >= DEBUG |
---|
[3293] | 200 | #define PRINT4 \ |
---|
[4373] | 201 | if (SOFT_DEBUG_LEVEL >= DEBUG) \ |
---|
[5075] | 202 | PRINT_EXEC |
---|
[4608] | 203 | #else |
---|
[3395] | 204 | #define PRINT4 if (NO) |
---|
[3293] | 205 | #endif |
---|
[3395] | 206 | |
---|
[4373] | 207 | #if HARD_DEBUG_LEVEL >= vDEBUG |
---|
[3548] | 208 | #define PRINT5 \ |
---|
[4373] | 209 | if (SOFT_DEBUG_LEVEL >= vDEBUG) \ |
---|
[5075] | 210 | PRINT_EXEC("VERYDEBUG::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC |
---|
[4608] | 211 | #else |
---|
[3548] | 212 | #define PRINT5 if (NO) |
---|
| 213 | #endif |
---|
[3395] | 214 | |
---|
[3548] | 215 | |
---|
[4608] | 216 | #else |
---|
[3395] | 217 | #define PRINT(x) if (NO) |
---|
[3293] | 218 | #endif |
---|
| 219 | |
---|
| 220 | #define PRINT0 \ |
---|
[5075] | 221 | PRINT_EXEC |
---|
[3293] | 222 | |
---|
[3204] | 223 | #endif /* _DEBUG_H */ |
---|