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
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
[3590]24#if HAVE_CONFIG_H
25#include <config.h> 
26#endif
27
28#include <stdio.h>
29
30// DEFINE ERROR MODES
[3395]31#define NO              0
[3480]32#define ERR             1
33#define WARN            2
34#define INFO            3
[3395]35#define DEBUGING        4
[3548]36#define vDEBUGING       5
[3293]37
[3590]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
[3439]51
[3590]52#define verbose DEBUG_SPECIAL_MODULE
[3395]53
[3590]54#endif
[3293]55///////////////////////////////////////////////////
56/// PRINTF: prints with filename and linenumber ///
57///////////////////////////////////////////////////
58
[3433]59#ifdef DEBUG
[3590]60
[3205]61#define PRINTF(x) \
62           PRINTF ## x
63
[3480]64#if DEBUG >= ERR
[3205]65#define PRINTF1 \
[3480]66    if (verbose >= ERR) \
[3511]67      printf("ERROR::%s:%d:", __FILE__, __LINE__) && printf
[3205]68#else
[3395]69#define PRINTF1 if (NO)
[3205]70#endif
71     
[3480]72#if DEBUG >= WARN
[3205]73#define PRINTF2 \
[3480]74     if (verbose >= WARN) \
[3511]75       printf("WARNING::%s:%d:", __FILE__, __LINE__) && printf
[3206]76         
[3205]77#else
[3395]78#define PRINTF2 if (NO)
[3205]79#endif
80     
[3480]81#if DEBUG >= INFO
[3205]82#define PRINTF3 \
[3480]83     if (verbose >= INFO) \
[3511]84       printf("INFO::%s:%d:", __FILE__, __LINE__) && printf
[3205]85#else
[3395]86#define PRINTF3 if (NO)
[3205]87#endif
88     
[3395]89#if DEBUG >= DEBUGING
[3205]90#define PRINTF4 \
[3395]91     if (verbose >= DEBUGING) \
[3511]92       printf("DEBUG::%s:%d:", __FILE__, __LINE__) && printf
[3205]93#else
[3395]94#define PRINTF4 if (NO)
[3205]95#endif
96     
[3548]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   
[3204]105#else 
[3395]106#define PRINTF(x) if (NO)
[3204]107#endif
108
[3206]109#define PRINTF0 \
[3212]110    printf("%s:%d::", __FILE__, __LINE__) && printf
[3204]111
[3293]112
113///////////////////////////////////////////////////
114///  PRINT: just prints output as is            ///
115///////////////////////////////////////////////////
116#ifdef  DEBUG
117#define PRINT(x) \
[3395]118  PRINT ## x
[3293]119
[3480]120#if DEBUG >= ERR
[3395]121#define PRINT1  \
[3480]122  if (verbose >= ERR)   \
[3395]123    printf
[3293]124#else
[3395]125#define PRINT1 if (NO)
[3293]126#endif
[3395]127
[3480]128#if DEBUG >= WARN
[3293]129#define PRINT2 \
[3480]130  if (verbose >= WARN) \
[3395]131    printf
[3293]132
133#else
[3395]134#define PRINT2 if (NO)
[3293]135#endif
[3395]136
[3480]137#if DEBUG >= INFO
[3293]138#define PRINT3 \
[3480]139  if (verbose >= INFO) \
[3395]140    printf
141#else
142#define PRINT3 if (NO)
[3293]143#endif
[3395]144
145#if DEBUG >= DEBUGING
[3293]146#define PRINT4 \
[3395]147  if (verbose >= DEBUGING) \
148    printf
[3293]149#else
[3395]150#define PRINT4 if (NO)
[3293]151#endif
[3395]152
[3548]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
[3395]160
[3548]161
[3293]162#else 
[3395]163#define PRINT(x) if (NO)
[3293]164#endif
165
166#define PRINT0 \
[3395]167  printf
[3293]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
[3395]181#define COUT1 if (NO) cout
[3293]182#endif
183     
184#if DEBUG >= 2
185#define COUT2 \
186     if (verbose >= 2 ) \
187       cout
188
189#else
[3395]190#define COUT2 if (NO) cout
[3293]191#endif
192     
193#if DEBUG >= 3
194#define COUT3 \
195     if (verbose >= 3 ) \
196       cout
197#else
[3395]198#define COUT3 if (NO) cout
[3293]199#endif
200     
201#if DEBUG >= 4
202#define COUT4 \
203     if (verbose >= 4 ) \
204       cout
205#else
[3395]206#define COUT4 if (NO) cout
[3293]207#endif
208     
209     
210#else 
[3395]211#define COUT(x) if (NO) cout
[3293]212#endif
213
214#define COUT0 \
215           cout
216
[3204]217#endif /* _DEBUG_H */
Note: See TracBrowser for help on using the repository browser.