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