Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/defs/debug.h @ 3590

Last change on this file since 3590 was 3590, checked in by bensch, 21 years ago

orxonox/trunk: updated debug.h: now possibility to log per module (compile-time)

  1. write in the cc-file at the beginnig !!BEFORE ANY INCLUDES!!

#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_[MODULENAME]
where [MODULNAME] is a name of a module that can be defined in debug.h

  1. define a new MODULE: easy just write a new one under the other ones in DEBUG.h
  1. if you do not wish special loggin everything stays as is, and you do not have to worry. (then de verbose will be set from orxonox.cc: int verbose)
File size: 4.0 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#if HAVE_CONFIG_H
25#include <config.h> 
26#endif
27
28#include <stdio.h>
29
30// DEFINE ERROR MODES
31#define NO              0
32#define ERR             1
33#define WARN            2
34#define INFO            3
35#define DEBUGING        4
36#define vDEBUGING       5
37
38#ifndef DEBUG_SPECIAL_MODULE
39extern int verbose;
40#else
41// DEFINE MODULES
42#define DEBUG_MODULE_WORLD              0
43#define DEBUG_MODULE_PNODE              0
44#define DEBUG_MODULE_TRACKMANAGER       0
45#define DEBUG_MODULE_LIGHT              0
46#define DEBUG_MODULE_WORLD_ENTITY       0
47#define DEBUG_MODULE_PLAYER             0
48#define DEBUG_MODULE_PNODE              0
49#define DEBUG_MODULE_IMPORTER           0
50#define DEBUG_MODULE_MATH               0
51
52#define verbose DEBUG_SPECIAL_MODULE
53
54#endif
55///////////////////////////////////////////////////
56/// PRINTF: prints with filename and linenumber ///
57///////////////////////////////////////////////////
58
59#ifdef DEBUG
60
61#define PRINTF(x) \
62           PRINTF ## x
63
64#if DEBUG >= ERR
65#define PRINTF1 \
66    if (verbose >= ERR) \
67      printf("ERROR::%s:%d:", __FILE__, __LINE__) && printf
68#else
69#define PRINTF1 if (NO)
70#endif
71     
72#if DEBUG >= WARN
73#define PRINTF2 \
74     if (verbose >= WARN) \
75       printf("WARNING::%s:%d:", __FILE__, __LINE__) && printf
76         
77#else
78#define PRINTF2 if (NO)
79#endif
80     
81#if DEBUG >= INFO
82#define PRINTF3 \
83     if (verbose >= INFO) \
84       printf("INFO::%s:%d:", __FILE__, __LINE__) && printf
85#else
86#define PRINTF3 if (NO)
87#endif
88     
89#if DEBUG >= DEBUGING
90#define PRINTF4 \
91     if (verbose >= DEBUGING) \
92       printf("DEBUG::%s:%d:", __FILE__, __LINE__) && printf
93#else
94#define PRINTF4 if (NO)
95#endif
96     
97#if DEBUG >= vDEBUGING
98#define PRINTF5 \
99     if (verbose >= vDEBUGING) \
100       printf("VERYDEBUG::%s:%d:", __FILE__, __LINE__) && printf
101#else
102#define PRINTF5 if (NO)
103#endif
104   
105#else 
106#define PRINTF(x) if (NO)
107#endif
108
109#define PRINTF0 \
110    printf("%s:%d::", __FILE__, __LINE__) && printf
111
112
113///////////////////////////////////////////////////
114///  PRINT: just prints output as is            ///
115///////////////////////////////////////////////////
116#ifdef  DEBUG
117#define PRINT(x) \
118  PRINT ## x
119
120#if DEBUG >= ERR
121#define PRINT1  \
122  if (verbose >= ERR)   \
123    printf
124#else
125#define PRINT1 if (NO)
126#endif
127
128#if DEBUG >= WARN
129#define PRINT2 \
130  if (verbose >= WARN) \
131    printf
132
133#else
134#define PRINT2 if (NO)
135#endif
136
137#if DEBUG >= INFO
138#define PRINT3 \
139  if (verbose >= INFO) \
140    printf
141#else
142#define PRINT3 if (NO)
143#endif
144
145#if DEBUG >= DEBUGING
146#define PRINT4 \
147  if (verbose >= DEBUGING) \
148    printf
149#else
150#define PRINT4 if (NO)
151#endif
152
153#if DEBUG >= vDEBUGING
154#define PRINT5 \
155     if (verbose >= vDEBUGING) \
156       printf("VERYDEBUG::%s:%d:", __FILE__, __LINE__) && printf
157#else
158#define PRINT5 if (NO)
159#endif
160
161
162#else 
163#define PRINT(x) if (NO)
164#endif
165
166#define PRINT0 \
167  printf
168
169///////////////////////////////////////////////////
170/// COUT: simple cout print with verbose-check  ///
171///////////////////////////////////////////////////
172#ifdef  DEBUG
173#define COUT(x) \
174           COUT ## x
175
176#if DEBUG >= 1
177#define COUT1 \
178    if (verbose >= 1 ) \
179      cout
180#else
181#define COUT1 if (NO) cout
182#endif
183     
184#if DEBUG >= 2
185#define COUT2 \
186     if (verbose >= 2 ) \
187       cout
188
189#else
190#define COUT2 if (NO) cout
191#endif
192     
193#if DEBUG >= 3
194#define COUT3 \
195     if (verbose >= 3 ) \
196       cout
197#else
198#define COUT3 if (NO) cout
199#endif
200     
201#if DEBUG >= 4
202#define COUT4 \
203     if (verbose >= 4 ) \
204       cout
205#else
206#define COUT4 if (NO) cout
207#endif
208     
209     
210#else 
211#define COUT(x) if (NO) cout
212#endif
213
214#define COUT0 \
215           cout
216
217#endif /* _DEBUG_H */
Note: See TracBrowser for help on using the repository browser.