Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/shadows/src/debug.h @ 3714

Last change on this file since 3714 was 3395, checked in by bensch, 20 years ago

orxonox/trunk: adapted PRINTF/PRINT/COUT, now they should behave properly.

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