Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 3542 was 3511, checked in by bensch, 20 years ago

orxonox/trunk: nicer debug-output

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