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