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