[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 | |
---|
[6834] | 91 | #define DEBUG_MODULE_STORY_ENTITY 2 |
---|
| 92 | |
---|
[5440] | 93 | #define DEBUG_MODULE_WEAPON 2 |
---|
[3439] | 94 | |
---|
[5440] | 95 | #define HARD_DEBUG_LEVEL DEBUG_SPECIAL_MODULE |
---|
| 96 | |
---|
| 97 | #endif /* DEBUG_SPECIAL_MODULE */ |
---|
[3592] | 98 | #endif /* MODULAR_DEBUG */ |
---|
[4373] | 99 | |
---|
[3293] | 100 | /////////////////////////////////////////////////// |
---|
| 101 | /// PRINTF: prints with filename and linenumber /// |
---|
| 102 | /////////////////////////////////////////////////// |
---|
[4373] | 103 | #define PRINTFNO PRINTF0 |
---|
| 104 | #define PRINTFERR PRINTF1 |
---|
| 105 | #define PRINTFWARN PRINTF2 |
---|
| 106 | #define PRINTFINFO PRINTF3 |
---|
| 107 | #define PRINTFDEBUG PRINTF4 |
---|
| 108 | #define PRINTFVDEBUG PRINTF5 |
---|
[3293] | 109 | |
---|
[5183] | 110 | #if DEBUG <= 3 |
---|
[5076] | 111 | #define PRINTF(x) PRINT(x) |
---|
[5183] | 112 | #endif |
---|
[5822] | 113 | #ifndef NO_SHELL |
---|
[6142] | 114 | #define PRINT_EXEC ShellBuffer::addBufferLineStatic |
---|
[5822] | 115 | #else /* NO_SHELL */ |
---|
| 116 | #define PRINT_EXEC printf |
---|
| 117 | #endif |
---|
[5075] | 118 | |
---|
[5076] | 119 | #ifndef PRINTF |
---|
[3433] | 120 | #ifdef DEBUG |
---|
[3590] | 121 | |
---|
[3205] | 122 | #define PRINTF(x) \ |
---|
| 123 | PRINTF ## x |
---|
| 124 | |
---|
[3592] | 125 | #if HARD_DEBUG_LEVEL >= ERR |
---|
[3205] | 126 | #define PRINTF1 \ |
---|
[3601] | 127 | if (SOFT_DEBUG_LEVEL >= ERR) \ |
---|
[5299] | 128 | printf("(EE)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC |
---|
[4608] | 129 | #else |
---|
[3395] | 130 | #define PRINTF1 if (NO) |
---|
[3205] | 131 | #endif |
---|
[4608] | 132 | |
---|
[3592] | 133 | #if HARD_DEBUG_LEVEL >= WARN |
---|
[3205] | 134 | #define PRINTF2 \ |
---|
[3601] | 135 | if (SOFT_DEBUG_LEVEL >= WARN) \ |
---|
[5299] | 136 | printf("(WW)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC |
---|
[4608] | 137 | |
---|
| 138 | #else |
---|
[3395] | 139 | #define PRINTF2 if (NO) |
---|
[3205] | 140 | #endif |
---|
[4608] | 141 | |
---|
[3592] | 142 | #if HARD_DEBUG_LEVEL >= INFO |
---|
[3205] | 143 | #define PRINTF3 \ |
---|
[3601] | 144 | if (SOFT_DEBUG_LEVEL >= INFO) \ |
---|
[5299] | 145 | printf("(II)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC |
---|
[4608] | 146 | #else |
---|
[3395] | 147 | #define PRINTF3 if (NO) |
---|
[3205] | 148 | #endif |
---|
[4608] | 149 | |
---|
[4373] | 150 | #if HARD_DEBUG_LEVEL >= DEBUG |
---|
[3205] | 151 | #define PRINTF4 \ |
---|
[4373] | 152 | if (SOFT_DEBUG_LEVEL >= DEBUG) \ |
---|
[5299] | 153 | printf("(DD)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC |
---|
[4608] | 154 | #else |
---|
[3395] | 155 | #define PRINTF4 if (NO) |
---|
[3205] | 156 | #endif |
---|
[4608] | 157 | |
---|
[4373] | 158 | #if HARD_DEBUG_LEVEL >= vDEBUG |
---|
[3548] | 159 | #define PRINTF5 \ |
---|
[4373] | 160 | if (SOFT_DEBUG_LEVEL >= vDEBUG) \ |
---|
[5299] | 161 | printf("(VD)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC |
---|
[4608] | 162 | #else |
---|
[3548] | 163 | #define PRINTF5 if (NO) |
---|
| 164 | #endif |
---|
[4608] | 165 | |
---|
| 166 | #else |
---|
[3395] | 167 | #define PRINTF(x) if (NO) |
---|
[3204] | 168 | #endif |
---|
| 169 | |
---|
[3206] | 170 | #define PRINTF0 \ |
---|
[5075] | 171 | printf("%s:%d::", __FILE__, __LINE__) && PRINT_EXEC |
---|
[5076] | 172 | #endif |
---|
[3204] | 173 | |
---|
[3293] | 174 | /////////////////////////////////////////////////// |
---|
| 175 | /// PRINT: just prints output as is /// |
---|
| 176 | /////////////////////////////////////////////////// |
---|
[4373] | 177 | #define PRINTNO PRINT0 |
---|
| 178 | #define PRINTERR PRINT1 |
---|
| 179 | #define PRINTWARN PRINT2 |
---|
| 180 | #define PRINTINFO PRINT3 |
---|
| 181 | #define PRINTDEBUG PRINT4 |
---|
| 182 | #define PRINTVDEBUG PRINT5 |
---|
| 183 | |
---|
[3293] | 184 | #ifdef DEBUG |
---|
| 185 | #define PRINT(x) \ |
---|
[3395] | 186 | PRINT ## x |
---|
[3293] | 187 | |
---|
[3592] | 188 | #if HARD_DEBUG_LEVEL >= ERR |
---|
[4608] | 189 | #define PRINT1 \ |
---|
| 190 | if (SOFT_DEBUG_LEVEL >= ERR) \ |
---|
[5075] | 191 | PRINT_EXEC |
---|
[4608] | 192 | #else |
---|
[3395] | 193 | #define PRINT1 if (NO) |
---|
[3293] | 194 | #endif |
---|
[3395] | 195 | |
---|
[3592] | 196 | #if HARD_DEBUG_LEVEL >= WARN |
---|
[3293] | 197 | #define PRINT2 \ |
---|
[3601] | 198 | if (SOFT_DEBUG_LEVEL >= WARN) \ |
---|
[5075] | 199 | PRINT_EXEC |
---|
[3293] | 200 | |
---|
[4608] | 201 | #else |
---|
[3395] | 202 | #define PRINT2 if (NO) |
---|
[3293] | 203 | #endif |
---|
[3395] | 204 | |
---|
[3592] | 205 | #if HARD_DEBUG_LEVEL >= INFO |
---|
[3293] | 206 | #define PRINT3 \ |
---|
[3601] | 207 | if (SOFT_DEBUG_LEVEL >= INFO) \ |
---|
[5075] | 208 | PRINT_EXEC |
---|
[4608] | 209 | #else |
---|
[3395] | 210 | #define PRINT3 if (NO) |
---|
[3293] | 211 | #endif |
---|
[3395] | 212 | |
---|
[4373] | 213 | #if HARD_DEBUG_LEVEL >= DEBUG |
---|
[3293] | 214 | #define PRINT4 \ |
---|
[4373] | 215 | if (SOFT_DEBUG_LEVEL >= DEBUG) \ |
---|
[5075] | 216 | PRINT_EXEC |
---|
[4608] | 217 | #else |
---|
[3395] | 218 | #define PRINT4 if (NO) |
---|
[3293] | 219 | #endif |
---|
[3395] | 220 | |
---|
[4373] | 221 | #if HARD_DEBUG_LEVEL >= vDEBUG |
---|
[3548] | 222 | #define PRINT5 \ |
---|
[4373] | 223 | if (SOFT_DEBUG_LEVEL >= vDEBUG) \ |
---|
[5299] | 224 | PRINT_EXEC |
---|
[4608] | 225 | #else |
---|
[3548] | 226 | #define PRINT5 if (NO) |
---|
| 227 | #endif |
---|
[3395] | 228 | |
---|
[3548] | 229 | |
---|
[4608] | 230 | #else |
---|
[3395] | 231 | #define PRINT(x) if (NO) |
---|
[3293] | 232 | #endif |
---|
| 233 | |
---|
| 234 | #define PRINT0 \ |
---|
[5075] | 235 | PRINT_EXEC |
---|
[3293] | 236 | |
---|
[3204] | 237 | #endif /* _DEBUG_H */ |
---|