Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/orxonox/core/Debug.h @ 680

Last change on this file since 680 was 670, checked in by landauf, 18 years ago

copyright notes

File size: 6.5 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *
4 *
5 *   License notice:
6 *
7 *   This program is free software; you can redistribute it and/or
8 *   modify it under the terms of the GNU General Public License
9 *   as published by the Free Software Foundation; either version 2
10 *   of the License, or (at your option) any later version.
11 *
12 *   This program is distributed in the hope that it will be useful,
13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 *   GNU General Public License for more details.
16 *
17 *   You should have received a copy of the GNU General Public License
18 *   along with this program; if not, write to the Free Software
19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 *
21 *   Author:
22 *      Benjamin Grauer
23 *   Co-authors:
24 *      Fabian 'x3n' Landau
25 *
26 */
27
28/*!
29 * @file Debug.h
30 * @brief Handles the output for different verbose-modes.
31 *
32 * There are two modes: HARD and SOFT. HARD is precessed during compiletime, while SOFT is for runtime.
33 */
34
35#ifndef _Debug_H__
36#define _Debug_H__
37
38#include <stdio.h>
39
40int getSoftDebugLevel();
41
42// DEFINE ERROR MODES
43#define ORX_NONE            0
44#define ORX_ERROR           1
45#define ORX_WARNING         2
46#define ORX_INFO            3
47#define ORX_DEBUG           4
48#define ORX_vDEBUG          5
49
50//definitions
51#define ORX_PRINT_DEBUG_OUTPUT 1 // <-- fix that! should be a configurable setting
52
53#define ORX_HARD_DEBUG_LEVEL ORX_DEBUG
54//#define ORX_SOFT_DEBUG_LEVEL ORX_WARNING // <-- fix that! should be a configurable setting
55
56///////////////////////////////////////////////////
57/// PRINTF: prints with filename and linenumber ///
58///////////////////////////////////////////////////
59#define PRINTFORX_NONE    PRINTF0
60#define PRINTFORX_ERROR   PRINTF1
61#define PRINTFORX_WARNING PRINTF2
62#define PRINTFORX_INFO    PRINTF3
63#define PRINTFORX_DEBUG   PRINTF4
64#define PRINTFORX_vDEBUG  PRINTF5
65
66#define PRINT_EXEC  printf
67#define COUT_EXEC   std::cout
68
69#ifndef PRINTF
70 #if ORX_PRINT_DEBUG_OUTPUT
71
72  #define PRINTF(x) \
73   PRINTF ## x
74
75  #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR
76   #define PRINTF1 \
77    if (getSoftDebugLevel() >= ORX_ERROR) \
78     printf("Error (in %s, line %d): ", __FILE__, __LINE__), PRINT_EXEC
79  #else
80   #define PRINTF1 if (ORX_NONE) PRINT_EXEC
81  #endif
82
83  #if ORX_HARD_DEBUG_LEVEL >= ORX_WARNING
84   #define PRINTF2 \
85    if (getSoftDebugLevel() >= ORX_WARNING) \
86     printf("Warning (in %s, line %d): ", __FILE__, __LINE__), PRINT_EXEC
87  #else
88   #define PRINTF2 if (ORX_NONE) PRINT_EXEC
89  #endif
90
91  #if ORX_HARD_DEBUG_LEVEL >= ORX_INFO
92   #define PRINTF3 \
93    if (getSoftDebugLevel() >= ORX_INFO) \
94     printf("Info (in %s, line %d): ", __FILE__, __LINE__), PRINT_EXEC
95  #else
96   #define PRINTF3 if (ORX_NONE) PRINT_EXEC
97  #endif
98
99  #if ORX_HARD_DEBUG_LEVEL >= ORX_DEBUG
100   #define PRINTF4 \
101    if (getSoftDebugLevel() >= ORX_DEBUG) \
102     printf("Debug (in %s, line %d): ", __FILE__, __LINE__), PRINT_EXEC
103  #else
104   #define PRINTF4 if (ORX_NONE) PRINT_EXEC
105  #endif
106
107  #if ORX_HARD_DEBUG_LEVEL >= ORX_vDEBUG
108   #define PRINTF5 \
109    if (getSoftDebugLevel() >= ORX_vDEBUG) \
110     printf("vDebug (in %s, line %d): ", __FILE__, __LINE__), PRINT_EXEC
111  #else
112   #define PRINTF5 if (ORX_NONE) PRINT_EXEC
113  #endif
114
115 #else /* if ORX_PRINT_DEBUG_OUTPUT */
116  #define PRINTF(x) if (ORX_NONE) PRINT_EXEC
117 #endif /* if ORX_PRINT_DEBUG_OUTPUT */
118
119 #define PRINTF0 \
120  PRINT_EXEC
121#endif /* ifndef PRINTF */
122
123///////////////////////////////////////////////////
124///  PRINT: just prints output as is            ///
125///////////////////////////////////////////////////
126#define PRINTORX_NONE    PRINT0
127#define PRINTORX_ERROR   PRINT1
128#define PRINTORX_WARNING PRINT2
129#define PRINTORX_INFO    PRINT3
130#define PRINTORX_DEBUG   PRINT4
131#define PRINTORX_vDEBUG  PRINT5
132
133#ifndef PRINT
134 #if ORX_PRINT_DEBUG_OUTPUT
135  #define PRINT(x) \
136   PRINT ## x
137
138  #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR
139   #define PRINT1  \
140    if (getSoftDebugLevel() >= ORX_ERROR)  \
141     PRINT_EXEC
142  #else
143   #define PRINT1 if (ORX_NONE) PRINT_EXEC
144  #endif
145
146  #if ORX_HARD_DEBUG_LEVEL >= ORX_WARNING
147   #define PRINT2 \
148    if (getSoftDebugLevel() >= ORX_WARNING) \
149     PRINT_EXEC
150  #else
151   #define PRINT2 if (ORX_NONE) PRINT_EXEC
152  #endif
153
154  #if ORX_HARD_DEBUG_LEVEL >= ORX_INFO
155   #define PRINT3 \
156    if (getSoftDebugLevel() >= ORX_INFO) \
157     PRINT_EXEC
158  #else
159   #define PRINT3 if (ORX_NONE) PRINT_EXEC
160  #endif
161
162  #if ORX_HARD_DEBUG_LEVEL >= ORX_DEBUG
163   #define PRINT4 \
164    if (getSoftDebugLevel() >= ORX_DEBUG) \
165     PRINT_EXEC
166  #else
167   #define PRINT4 if (ORX_NONE) PRINT_EXEC
168  #endif
169
170  #if ORX_HARD_DEBUG_LEVEL >= ORX_vDEBUG
171   #define PRINT5 \
172    if (getSoftDebugLevel() >= ORX_vDEBUG) \
173     PRINT_EXEC
174  #else
175   #define PRINT5 if (ORX_NONE) PRINT_EXEC
176  #endif
177
178 #else /* if ORX_PRINT_DEBUG_OUTPUT */
179  #define PRINT(x) if (ORX_NONE) PRINT_EXEC
180 #endif /* if ORX_PRINT_DEBUG_OUTPUT */
181
182 #define PRINT0 \
183  PRINT_EXEC
184#endif /* ifndef PRINT */
185
186
187////////////////////////////////////////////////////////
188///  COUT: just prints output as is with std::cout   ///
189////////////////////////////////////////////////////////
190#define COUTORX_NONE    COUT0
191#define COUTORX_ERROR   COUT1
192#define COUTORX_WARNING COUT2
193#define COUTORX_INFO    COUT3
194#define COUTORX_DEBUG   COUT4
195#define COUTORX_vDEBUG  COUT5
196
197#ifndef COUT
198 #if ORX_PRINT_DEBUG_OUTPUT
199  #define COUT(x) \
200   COUT ## x
201
202  #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR
203   #define COUT1  \
204    if (getSoftDebugLevel() >= ORX_ERROR)  \
205     COUT_EXEC
206  #else
207   #define COUT1 if (ORX_NONE)\
208    COUT_EXEC
209  #endif
210
211  #if ORX_HARD_DEBUG_LEVEL >= ORX_WARNING
212   #define COUT2 \
213    if (getSoftDebugLevel() >= ORX_WARNING) \
214     COUT_EXEC
215  #else
216   #define COUT2 if (ORX_NONE) \
217    COUT_EXEC
218  #endif
219
220  #if ORX_HARD_DEBUG_LEVEL >= ORX_INFO
221   #define COUT3 \
222    if (getSoftDebugLevel() >= ORX_INFO) \
223     COUT_EXEC
224  #else
225   #define COUT3 if (ORX_NONE) \
226    COUT_EXEC
227  #endif
228
229  #if ORX_HARD_DEBUG_LEVEL >= ORX_DEBUG
230   #define COUT4 \
231    if (getSoftDebugLevel() >= ORX_DEBUG) \
232     COUT_EXEC
233  #else
234   #define COUT4 if (ORX_NONE) \
235    COUT_EXEC
236  #endif
237
238  #if ORX_HARD_DEBUG_LEVEL >= ORX_vDEBUG
239   #define COUT5 \
240    if (getSoftDebugLevel() >= ORX_vDEBUG) \
241     COUT_EXEC
242  #else
243   #define COUT5 if (ORX_NONE) \
244    COUT_EXEC
245  #endif
246
247 #else /* if ORX_PRINT_DEBUG_OUTPUT */
248  #define COUT(x) if (ORX_NONE) \
249   COUT_EXEC
250 #endif /* if ORX_PRINT_DEBUG_OUTPUT */
251
252 #define COUT0 \
253  COUT_EXEC
254#endif /* ifndef COUT */
255
256#endif /* _Debug_H__ */
Note: See TracBrowser for help on using the repository browser.