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