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