Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 543 was 499, checked in by landauf, 16 years ago

added Debug.h from objecthierarchy

File size: 5.9 KB
Line 
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 the output for different verbose-modes.
19 *
20 * There are two modes: HARD and SOFT. HARD is precessed during compiletime, while SOFT is for runtime.
21 */
22
23#ifndef _Debug_H__
24#define _Debug_H__
25
26#include <stdio.h>
27
28// DEFINE ERROR MODES
29#define ORX_NONE            0
30#define ORX_ERROR           1
31#define ORX_WARNING         2
32#define ORX_INFO            3
33#define ORX_DEBUG           4
34#define ORX_vDEBUG          5
35
36//definitions
37#define ORX_PRINT_DEBUG_OUTPUT 1 // <-- fix that! should be a configurable setting
38
39#define ORX_HARD_DEBUG_LEVEL ORX_DEBUG
40#define ORX_SOFT_DEBUG_LEVEL ORX_WARNING // <-- fix that! should be a configurable setting
41
42///////////////////////////////////////////////////
43/// PRINTF: prints with filename and linenumber ///
44///////////////////////////////////////////////////
45#define PRINTFORX_NONE    PRINTF0
46#define PRINTFORX_ERROR   PRINTF1
47#define PRINTFORX_WARNING PRINTF2
48#define PRINTFORX_INFO    PRINTF3
49#define PRINTFORX_DEBUG   PRINTF4
50#define PRINTFORX_vDEBUG  PRINTF5
51
52#define PRINT_EXEC  printf
53#define COUT_EXEC   std::cout
54
55#ifndef PRINTF
56 #if ORX_PRINT_DEBUG_OUTPUT
57
58  #define PRINTF(x) \
59   PRINTF ## x
60
61  #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR
62   #define PRINTF1 \
63    if (ORX_SOFT_DEBUG_LEVEL >= ORX_ERROR) \
64     printf("Error (in %s, line %d): ", __FILE__, __LINE__), PRINT_EXEC
65  #else
66   #define PRINTF1 if (ORX_NONE) PRINT_EXEC
67  #endif
68
69  #if ORX_HARD_DEBUG_LEVEL >= ORX_WARNING
70   #define PRINTF2 \
71    if (ORX_SOFT_DEBUG_LEVEL >= ORX_WARNING) \
72     printf("Warning (in %s, line %d): ", __FILE__, __LINE__), PRINT_EXEC
73  #else
74   #define PRINTF2 if (ORX_NONE) PRINT_EXEC
75  #endif
76
77  #if ORX_HARD_DEBUG_LEVEL >= ORX_INFO
78   #define PRINTF3 \
79    if (ORX_SOFT_DEBUG_LEVEL >= ORX_INFO) \
80     printf("Info (in %s, line %d): ", __FILE__, __LINE__), PRINT_EXEC
81  #else
82   #define PRINTF3 if (ORX_NONE) PRINT_EXEC
83  #endif
84
85  #if ORX_HARD_DEBUG_LEVEL >= ORX_DEBUG
86   #define PRINTF4 \
87    if (ORX_SOFT_DEBUG_LEVEL >= ORX_DEBUG) \
88     printf("Debug (in %s, line %d): ", __FILE__, __LINE__), PRINT_EXEC
89  #else
90   #define PRINTF4 if (ORX_NONE) PRINT_EXEC
91  #endif
92
93  #if ORX_HARD_DEBUG_LEVEL >= ORX_vDEBUG
94   #define PRINTF5 \
95    if (ORX_SOFT_DEBUG_LEVEL >= ORX_vDEBUG) \
96     printf("vDebug (in %s, line %d): ", __FILE__, __LINE__), PRINT_EXEC
97  #else
98   #define PRINTF5 if (ORX_NONE) PRINT_EXEC
99  #endif
100
101 #else /* if ORX_PRINT_DEBUG_OUTPUT */
102  #define PRINTF(x) if (ORX_NONE) PRINT_EXEC
103 #endif /* if ORX_PRINT_DEBUG_OUTPUT */
104
105 #define PRINTF0 \
106  PRINT_EXEC
107#endif /* ifndef PRINTF */
108
109///////////////////////////////////////////////////
110///  PRINT: just prints output as is            ///
111///////////////////////////////////////////////////
112#define PRINTORX_NONE    PRINT0
113#define PRINTORX_ERROR   PRINT1
114#define PRINTORX_WARNING PRINT2
115#define PRINTORX_INFO    PRINT3
116#define PRINTORX_DEBUG   PRINT4
117#define PRINTORX_vDEBUG  PRINT5
118
119#ifndef PRINT
120 #if ORX_PRINT_DEBUG_OUTPUT
121  #define PRINT(x) \
122   PRINT ## x
123
124  #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR
125   #define PRINT1  \
126    if (ORX_SOFT_DEBUG_LEVEL >= ORX_ERROR)  \
127     PRINT_EXEC
128  #else
129   #define PRINT1 if (ORX_NONE) PRINT_EXEC
130  #endif
131
132  #if ORX_HARD_DEBUG_LEVEL >= ORX_WARNING
133   #define PRINT2 \
134    if (ORX_SOFT_DEBUG_LEVEL >= ORX_WARNING) \
135     PRINT_EXEC
136  #else
137   #define PRINT2 if (ORX_NONE) PRINT_EXEC
138  #endif
139
140  #if ORX_HARD_DEBUG_LEVEL >= ORX_INFO
141   #define PRINT3 \
142    if (ORX_SOFT_DEBUG_LEVEL >= ORX_INFO) \
143     PRINT_EXEC
144  #else
145   #define PRINT3 if (ORX_NONE) PRINT_EXEC
146  #endif
147
148  #if ORX_HARD_DEBUG_LEVEL >= ORX_DEBUG
149   #define PRINT4 \
150    if (ORX_SOFT_DEBUG_LEVEL >= ORX_DEBUG) \
151     PRINT_EXEC
152  #else
153   #define PRINT4 if (ORX_NONE) PRINT_EXEC
154  #endif
155
156  #if ORX_HARD_DEBUG_LEVEL >= ORX_vDEBUG
157   #define PRINT5 \
158    if (ORX_SOFT_DEBUG_LEVEL >= ORX_vDEBUG) \
159     PRINT_EXEC
160  #else
161   #define PRINT5 if (ORX_NONE) PRINT_EXEC
162  #endif
163
164 #else /* if ORX_PRINT_DEBUG_OUTPUT */
165  #define PRINT(x) if (ORX_NONE) PRINT_EXEC
166 #endif /* if ORX_PRINT_DEBUG_OUTPUT */
167
168 #define PRINT0 \
169  PRINT_EXEC
170#endif /* ifndef PRINT */
171
172
173////////////////////////////////////////////////////////
174///  COUT: just prints output as is with std::cout   ///
175////////////////////////////////////////////////////////
176#define COUTORX_NONE    COUT0
177#define COUTORX_ERROR   COUT1
178#define COUTORX_WARNING COUT2
179#define COUTORX_INFO    COUT3
180#define COUTORX_DEBUG   COUT4
181#define COUTORX_vDEBUG  COUT5
182
183#ifndef COUT
184 #if ORX_PRINT_DEBUG_OUTPUT
185  #define COUT(x) \
186   COUT ## x
187
188  #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR
189   #define COUT1  \
190    if (ORX_SOFT_DEBUG_LEVEL >= ORX_ERROR)  \
191     COUT_EXEC
192  #else
193   #define COUT1 if (ORX_NONE)\
194    COUT_EXEC
195  #endif
196
197  #if ORX_HARD_DEBUG_LEVEL >= ORX_WARNING
198   #define COUT2 \
199    if (ORX_SOFT_DEBUG_LEVEL >= ORX_WARNING) \
200     COUT_EXEC
201  #else
202   #define COUT2 if (ORX_NONE) \
203    COUT_EXEC
204  #endif
205
206  #if ORX_HARD_DEBUG_LEVEL >= ORX_INFO
207   #define COUT3 \
208    if (ORX_SOFT_DEBUG_LEVEL >= ORX_INFO) \
209     COUT_EXEC
210  #else
211   #define COUT3 if (ORX_NONE) \
212    COUT_EXEC
213  #endif
214
215  #if ORX_HARD_DEBUG_LEVEL >= ORX_DEBUG
216   #define COUT4 \
217    if (ORX_SOFT_DEBUG_LEVEL >= ORX_DEBUG) \
218     COUT_EXEC
219  #else
220   #define COUT4 if (ORX_NONE) \
221    COUT_EXEC
222  #endif
223
224  #if ORX_HARD_DEBUG_LEVEL >= ORX_vDEBUG
225   #define COUT5 \
226    if (ORX_SOFT_DEBUG_LEVEL >= ORX_vDEBUG) \
227     COUT_EXEC
228  #else
229   #define COUT5 if (ORX_NONE) \
230    COUT_EXEC
231  #endif
232
233 #else /* if ORX_PRINT_DEBUG_OUTPUT */
234  #define COUT(x) if (ORX_NONE) \
235   COUT_EXEC
236 #endif /* if ORX_PRINT_DEBUG_OUTPUT */
237
238 #define COUT0 \
239  COUT_EXEC
240#endif /* ifndef COUT */
241
242#endif /* _Debug_H__ */
Note: See TracBrowser for help on using the repository browser.