Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/util/Debug.h @ 1752

Last change on this file since 1752 was 1747, checked in by landauf, 16 years ago

merged core3 back to trunk

  • Property svn:eol-style set to native
File size: 6.2 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Benjamin Grauer
24 *   Co-authors:
25 *      Fabian 'x3n' Landau
26 *
27 */
28
29/**
30 * @file Debug.h
31 * @brief Handles the output for different verbose-modes.
32 *
33 * There are two modes: HARD and SOFT. HARD is precessed during compiletime, while SOFT is for runtime.
34 */
35
36#ifndef _Debug_H__
37#define _Debug_H__
38
39#include "UtilPrereqs.h"
40
41#include <stdio.h>
42
43#include "OutputHandler.h"
44
45
46/**
47    @brief Returns the soft debug level, stored in the only existing instance of the OutputHandler class, configured in the config-file.
48    @return The soft debug level
49*/
50static inline int getSoftDebugLevel()
51{
52    return orxonox::OutputHandler::getSoftDebugLevel();
53}
54
55
56// DEFINE ERROR MODES
57#define ORX_NONE            0
58#define ORX_ERROR           1
59#define ORX_WARNING         2
60#define ORX_INFO            3
61#define ORX_DEBUG           4
62#define ORX_VERBOSE         5
63#define ORX_ULTRA           6
64
65//definitions
66#define ORX_PRINT_DEBUG_OUTPUT 1
67#define ORX_HARD_DEBUG_LEVEL ORX_VERBOSE
68
69#define COUT_EXEC(x) orxonox::OutputHandler::getOutStream().setOutputLevel(x)
70
71////////////////////////////////////////////////////////
72///  COUT: just prints output as is with std::cout   ///
73////////////////////////////////////////////////////////
74#define COUTORX_NONE    COUT0
75#define COUTORX_ERROR   COUT1
76#define COUTORX_WARNING COUT2
77#define COUTORX_INFO    COUT3
78#define COUTORX_DEBUG   COUT4
79#define COUTORX_VERBOSE COUT5
80#define COUTORX_ULTRA   COUT6
81
82#ifndef COUT
83 #if ORX_PRINT_DEBUG_OUTPUT
84  #define COUT(x) \
85   COUT ## x
86
87  #if ORX_HARD_DEBUG_LEVEL >= ORX_NONE
88   #define COUT0 \
89    (getSoftDebugLevel() < ORX_NONE) ? COUT_EXEC(0) : COUT_EXEC(0)
90  #else
91   #define COUT0 \
92    false ? COUT_EXEC(0) : COUT_EXEC(0)
93  #endif
94
95  #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR
96   #define COUT1 \
97    (getSoftDebugLevel() < ORX_ERROR) ? COUT_EXEC(1) : COUT_EXEC(1)
98  #else
99   #define COUT1 \
100    false ? COUT_EXEC(1) : COUT_EXEC(1)
101  #endif
102
103  #if ORX_HARD_DEBUG_LEVEL >= ORX_WARNING
104   #define COUT2 \
105    (getSoftDebugLevel() < ORX_WARNING) ? COUT_EXEC(2) : COUT_EXEC(2)
106  #else
107   #define COUT2 \
108    false ? COUT_EXEC(2) : COUT_EXEC(2)
109  #endif
110
111  #if ORX_HARD_DEBUG_LEVEL >= ORX_INFO
112   #define COUT3 \
113    (getSoftDebugLevel() < ORX_INFO) ? COUT_EXEC(3) : COUT_EXEC(3)
114  #else
115   #define COUT3 \
116    false ? COUT_EXEC(3) : COUT_EXEC(3)
117  #endif
118
119  #if ORX_HARD_DEBUG_LEVEL >= ORX_DEBUG
120   #define COUT4 \
121    (getSoftDebugLevel() < ORX_DEBUG) ? COUT_EXEC(4) : COUT_EXEC(4)
122  #else
123   #define COUT4 \
124    false ? COUT_EXEC(4) : COUT_EXEC(4)
125  #endif
126
127  #if ORX_HARD_DEBUG_LEVEL >= ORX_VERBOSE
128   #define COUT5 \
129    (getSoftDebugLevel() < ORX_VERBOSE) ? COUT_EXEC(5) : COUT_EXEC(5)
130  #else
131   #define COUT5 \
132    false ? COUT_EXEC(5) : COUT_EXEC(5)
133  #endif
134
135  #if ORX_HARD_DEBUG_LEVEL >= ORX_ULTRA
136   #define COUT6 \
137    (getSoftDebugLevel() < ORX_ULTRA) ? COUT_EXEC(6) : COUT_EXEC(6)
138  #else
139   #define COUT6 \
140    false ? COUT_EXEC(6) : COUT_EXEC(6)
141  #endif
142
143 #else /* if ORX_PRINT_DEBUG_OUTPUT */
144  #define COUT(x) \
145    false ? COUT_EXEC(6) : COUT_EXEC(6)
146 #endif /* if ORX_PRINT_DEBUG_OUTPUT */
147
148#endif /* ifndef COUT */
149
150
151/////////////////////////////////////////////////////////////////////
152///  CCOUT: Prints output with std::cout and adds the classname   ///
153/////////////////////////////////////////////////////////////////////
154#define CCOUTORX_NONE    CCOUT0
155#define CCOUTORX_ERROR   CCOUT1
156#define CCOUTORX_WARNING CCOUT2
157#define CCOUTORX_INFO    CCOUT3
158#define CCOUTORX_DEBUG   CCOUT4
159#define CCOUTORX_VERBOSE CCOUT5
160#define CCOUTORX_ULTRA   CCOUT6
161
162#define CCOUT_EXEC(x) \
163  orxonox::OutputHandler::getOutStream().setOutputLevel(x) \
164  << this->getIdentifier()->getName() << ": "
165
166#ifndef CCOUT
167 #if ORX_PRINT_DEBUG_OUTPUT
168  #define CCOUT(x) \
169   CCOUT ## x
170
171  #if ORX_HARD_DEBUG_LEVEL >= ORX_NONE
172   #define CCOUT0 \
173    (getSoftDebugLevel() < ORX_NONE) ? COUT_EXEC(0) : CCOUT_EXEC(0)
174  #else
175   #define CCOUT0 \
176    false ? COUT_EXEC(0) : CCOUT_EXEC(0)
177  #endif
178
179  #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR
180   #define CCOUT1 \
181    (getSoftDebugLevel() < ORX_ERROR) ? COUT_EXEC(1) : CCOUT_EXEC(1)
182  #else
183   #define CCOUT1 \
184    false ? COUT_EXEC(1) : CCOUT_EXEC(1)
185  #endif
186
187  #if ORX_HARD_DEBUG_LEVEL >= ORX_WARNING
188   #define CCOUT2 \
189    (getSoftDebugLevel() < ORX_WARNING) ? COUT_EXEC(2) : CCOUT_EXEC(2)
190  #else
191   #define CCOUT2 \
192    false ? COUT_EXEC(2) : CCOUT_EXEC(2)
193  #endif
194
195  #if ORX_HARD_DEBUG_LEVEL >= ORX_INFO
196   #define CCOUT3 \
197    (getSoftDebugLevel() < ORX_INFO) ? COUT_EXEC(3) : CCOUT_EXEC(3)
198  #else
199   #define CCOUT3 \
200    false ? COUT_EXEC(3) : CCOUT_EXEC(3)
201  #endif
202
203  #if ORX_HARD_DEBUG_LEVEL >= ORX_DEBUG
204   #define CCOUT4 \
205    (getSoftDebugLevel() < ORX_DEBUG) ? COUT_EXEC(4) : CCOUT_EXEC(4)
206  #else
207   #define CCOUT4 \
208    false ? COUT_EXEC(4) : CCOUT_EXEC(4)
209  #endif
210
211  #if ORX_HARD_DEBUG_LEVEL >= ORX_VERBOSE
212   #define CCOUT5 \
213    (getSoftDebugLevel() < ORX_VERBOSE) ? COUT_EXEC(5) : CCOUT_EXEC(5)
214  #else
215   #define CCOUT5 \
216    false ? COUT_EXEC(5) : CCOUT_EXEC(5)
217  #endif
218
219  #if ORX_HARD_DEBUG_LEVEL >= ORX_ULTRA
220   #define CCOUT6 \
221    (getSoftDebugLevel() < ORX_ULTRA) ? COUT_EXEC(6) : CCOUT_EXEC(6)
222  #else
223   #define CCOUT6 \
224    false ? COUT_EXEC(6) : CCOUT_EXEC(6)
225  #endif
226
227 #else /* if ORX_PRINT_DEBUG_OUTPUT */
228  #define CCOUT(x) \
229   false ? CCOUT_EXEC(6) : CCOUT_EXEC(6)
230 #endif /* if ORX_PRINT_DEBUG_OUTPUT */
231
232#endif /* ifndef CCOUT */
233
234#endif /* _Debug_H__ */
Note: See TracBrowser for help on using the repository browser.