Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 9777 was 8282, checked in by bensch, 18 years ago

debug better

File size: 7.3 KB
RevLine 
[4608]1/*
[3395]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
[4608]16/*!
[5039]17 * @file debug.h
[7374]18 * @briefHandles output to console for different Verbose-Modes.
19 *
20 * There are two main modes HARD and SOFT. HARD is precessed during compileTime where SOFT is for runtime.
21 * @li HARD: One can choose between different modes. see: // DEFINE_MODULES
22 * @li SOFT: If you want each module can have its own variable for processing. just pass it to DEBUG_MODULE_SOFT
23 */
[3601]24
[3204]25#ifndef _DEBUG_H
26#define _DEBUG_H
27
[3863]28#include "confincl.h"
[5944]29#ifndef NO_SHELL
[7661]30#include "lib/shell/shell_buffer.h"
[5944]31#endif /* NO_SHELL */
[3590]32
33#include <stdio.h>
[6868]34#include <cassert>
[3590]35
36// DEFINE ERROR MODES
[7729]37#define ORX_NONE            0
38#define ORX_ERR             1
39#define ORX_WARN            2
40#define ORX_INFO            3
41#define ORX_DEBUG           4
42#define ORX_vDEBUG          5
[3293]43
[3592]44extern int verbose;
45
[3601]46//definitions
[3592]47#ifndef MODULAR_DEBUG
[7729]48 #define HARD_DEBUG_LEVEL ORX_DEBUG
[5440]49 #define SOFT_DEBUG_LEVEL verbose
[3592]50#else /* MODULAR_DEBUG */
[5440]51 #ifndef DEBUG_MODULE_SOFT
52  #define SOFT_DEBUG_LEVEL verbose
53 #else /* DEBUG_MODULE_SOFT */
54  #define SOFT_DEBUG_LEVEL DEBUG_MODULE_SOFT
55 #endif /* DEBUG_MODULE_SOFT */
[3601]56
[5440]57 #ifndef DEBUG_SPECIAL_MODULE
58  #define HARD_DEBUG_LEVEL DEBUG
59 #else /* DEBUG_SPECIAL_MODULE */
60  ////////////////////
61  // DEFINE MODULES //
62  ////////////////////
63  // FRAMEWORK
64  #define DEBUG_MODULE_BASE                  2
65  #define DEBUG_MODULE_ORXONOX               2
66  #define DEBUG_MODULE_WORLD                 2
67  #define DEBUG_MODULE_NETWORK               2
[5300]68
[5440]69  // LOADING
70  #define DEBUG_MODULE_LOAD                  2
71  #define DEBUG_MODULE_IMPORTER              2
[3591]72
[5440]73  // ENGINES
74  #define DEBUG_MODULE_GRAPHICS              2
[5476]75  #define DEBUG_MODULE_EVENT                 2
[5440]76  #define DEBUG_MODULE_PHYSICS               2
77  #define DEBUG_MODULE_GARBAGE_COLLECTOR     2
78  #define DEBUG_MODULE_OBJECT_MANAGER        2
79  #define DEBUG_MODULE_ANIM                  2
[7711]80  #define DEBUG_MODULE_COLLISION_DETECTION   2
[7819]81  #define DEBUG_MODULE_COLLISION_REACTION    2
[5440]82  #define DEBUG_MODULE_SPATIAL_SEPARATION    2
83  #define DEBUG_MODULE_GUI                   2
[5930]84  #define DEBUG_MODULE_SOUND                 2
[5300]85
[5440]86  // MISC
87  #define DEBUG_MODULE_TRACK_MANAGER         2
88  #define DEBUG_MODULE_MATH                  2
[5300]89
[5440]90  #define DEBUG_MODULE_PNODE                 2
91  #define DEBUG_MODULE_WORLD_ENTITY          2
[5300]92
[6834]93  #define DEBUG_MODULE_STORY_ENTITY          2
[7020]94  #define DEBUG_MODULE_GAME_RULES            2
[6834]95
[5440]96  #define DEBUG_MODULE_WEAPON                2
[3439]97
[5440]98  #define HARD_DEBUG_LEVEL DEBUG_SPECIAL_MODULE
99
100 #endif /* DEBUG_SPECIAL_MODULE */
[3592]101#endif /* MODULAR_DEBUG */
[4373]102
[3293]103///////////////////////////////////////////////////
104/// PRINTF: prints with filename and linenumber ///
105///////////////////////////////////////////////////
[7729]106#define PRINTFORX_NONE    PRINTF0
107#define PRINTFORX_ERR     PRINTF1
108#define PRINTFORX_WARN    PRINTF2
109#define PRINTFORX_INFO    PRINTF3
110#define PRINTFORX_DEBUG   PRINTF4
111#define PRINTFORX_VDEBUG  PRINTF5
[3293]112
[7729]113#if DEBUG_LEVEL <= 3
[5076]114#define PRINTF(x)        PRINT(x)
[5183]115#endif
[5822]116#ifndef NO_SHELL
[7374]117#define PRINT_EXEC       OrxShell::ShellBuffer::addBufferLineStatic
[7161]118#define COUT_EXEC        std::cout
[5822]119#else /* NO_SHELL */
120#define PRINT_EXEC       printf
[7161]121#define COUT_EXEC        std::cout
[5822]122#endif
[5075]123
[5076]124#ifndef PRINTF
[7729]125#ifdef ORX_DEBUG
[3590]126
[3205]127#define PRINTF(x) \
128           PRINTF ## x
129
[7729]130#if HARD_DEBUG_LEVEL >= ORX_ERR
[3205]131#define PRINTF1 \
[7729]132    if (SOFT_DEBUG_LEVEL >= ORX_ERR) \
[8145]133      printf("(EE)::%s:%d:", __FILE__, __LINE__), PRINT_EXEC
[4608]134#else
[8145]135#define PRINTF1 if (ORX_NONE) PRINT_EXEC
[3205]136#endif
[4608]137
[7729]138#if HARD_DEBUG_LEVEL >= ORX_WARN
[3205]139#define PRINTF2 \
[7729]140     if (SOFT_DEBUG_LEVEL >= ORX_WARN) \
[8145]141       printf("(WW)::%s:%d:", __FILE__, __LINE__), PRINT_EXEC
[4608]142
143#else
[8145]144#define PRINTF2 if (ORX_NONE) PRINT_EXEC
[3205]145#endif
[4608]146
[7729]147#if HARD_DEBUG_LEVEL >= ORX_INFO
[3205]148#define PRINTF3 \
[7729]149     if (SOFT_DEBUG_LEVEL >= ORX_INFO) \
[8145]150       printf("(II)::%s:%d:", __FILE__, __LINE__), PRINT_EXEC
[4608]151#else
[8145]152#define PRINTF3 if (ORX_NONE) PRINT_EXEC
[3205]153#endif
[4608]154
[7729]155#if HARD_DEBUG_LEVEL >= ORX_DEBUG
[3205]156#define PRINTF4 \
[7729]157     if (SOFT_DEBUG_LEVEL >= ORX_DEBUG) \
[8145]158       printf("(DD)::%s:%d:", __FILE__, __LINE__), PRINT_EXEC
[4608]159#else
[8145]160#define PRINTF4 if (ORX_NONE) PRINT_EXEC
[3205]161#endif
[4608]162
[7729]163#if HARD_DEBUG_LEVEL >= ORX_vDEBUG
[3548]164#define PRINTF5 \
[7729]165     if (SOFT_DEBUG_LEVEL >= ORX_vDEBUG) \
[8145]166       printf("(VD)::%s:%d:", __FILE__, __LINE__), PRINT_EXEC
[4608]167#else
[8145]168#define PRINTF5 if (ORX_NONE) PRINT_EXEC
[3548]169#endif
[4608]170
171#else
[8282]172#define PRINTF(x) if (ORX_NONE) PRINT_EXEC
[3204]173#endif
174
[3206]175#define PRINTF0 \
[8145]176    printf("%s:%d::", __FILE__, __LINE__), PRINT_EXEC
[5076]177#endif
[3204]178
[3293]179///////////////////////////////////////////////////
180///  PRINT: just prints output as is            ///
181///////////////////////////////////////////////////
[7729]182#define PRINTORX_NONE    PRINT0
183#define PRINTORX_ERR     PRINT1
184#define PRINTORX_WARN    PRINT2
185#define PRINTORX_INFO    PRINT3
186#define PRINTORX_DEBUG   PRINT4
187#define PRINTORX_vDEBUG  PRINT5
[4373]188
[7729]189#ifdef  DEBUG_LEVEL
[3293]190#define PRINT(x) \
[3395]191  PRINT ## x
[3293]192
[7729]193#if HARD_DEBUG_LEVEL >= ORX_ERR
[4608]194#define PRINT1  \
[7729]195  if (SOFT_DEBUG_LEVEL >= ORX_ERR)  \
[5075]196    PRINT_EXEC
[4608]197#else
[8145]198#define PRINT1 if (ORX_NONE) PRINT_EXEC
[3293]199#endif
[3395]200
[7729]201#if HARD_DEBUG_LEVEL >= ORX_WARN
[3293]202#define PRINT2 \
[7729]203  if (SOFT_DEBUG_LEVEL >= ORX_WARN) \
[5075]204    PRINT_EXEC
[3293]205
[4608]206#else
[8145]207#define PRINT2 if (ORX_NONE) PRINT_EXEC
[3293]208#endif
[3395]209
[7729]210#if HARD_DEBUG_LEVEL >= ORX_INFO
[3293]211#define PRINT3 \
[7729]212  if (SOFT_DEBUG_LEVEL >= ORX_INFO) \
[5075]213    PRINT_EXEC
[4608]214#else
[8145]215#define PRINT3 if (ORX_NONE) PRINT_EXEC
[3293]216#endif
[3395]217
[7729]218#if HARD_DEBUG_LEVEL >= ORX_DEBUG
[3293]219#define PRINT4 \
[7729]220  if (SOFT_DEBUG_LEVEL >= ORX_DEBUG) \
[5075]221    PRINT_EXEC
[4608]222#else
[8145]223#define PRINT4 if (ORX_NONE) PRINT_EXEC
[3293]224#endif
[3395]225
[7729]226#if HARD_DEBUG_LEVEL >= ORX_vDEBUG
[3548]227#define PRINT5 \
[7729]228     if (SOFT_DEBUG_LEVEL >= ORX_vDEBUG) \
[5299]229       PRINT_EXEC
[4608]230#else
[8145]231#define PRINT5 if (ORX_NONE) PRINT_EXEC
[3548]232#endif
[3395]233
[3548]234
[4608]235#else
[8282]236#define PRINT(x) if (ORX_NONE) PRINT_EXEC
[3293]237#endif
238
239#define PRINT0 \
[5075]240  PRINT_EXEC
[3293]241
[7161]242
243
244////////////////////////////////////////////////////////
245///  COUT: just prints output as is with std::cout   ///
246////////////////////////////////////////////////////////
[7729]247#define COUTORX_NONE    COUT0
248#define COUTORX_ERR     COUT1
249#define COUTORX_WARN    COUT2
250#define COUTORX_INFO    COUT3
251#define COUTORX_DEBUG   COUT4
252#define COUTORX_vDEBUG  COUT5
[7161]253
[7729]254#ifdef  DEBUG_LEVEL
[7161]255#define COUT(x) \
256  COUT ## x
257
[7729]258#if HARD_DEBUG_LEVEL >= ORX_ERR
[7161]259#define COUT1  \
[7729]260  if (SOFT_DEBUG_LEVEL >= ORX_ERR)  \
[7161]261    COUT_EXEC
262#else
[7729]263#define COUT1 if (ORX_NONE)\
[7161]264    COUT_EXEC
265#endif
266
[7729]267#if HARD_DEBUG_LEVEL >= ORX_WARN
[7161]268#define COUT2 \
[7729]269  if (SOFT_DEBUG_LEVEL >= ORX_WARN) \
[7161]270    COUT_EXEC
271
272#else
[7729]273#define COUT2 if (ORX_NONE) \
[7161]274    COUT_EXEC
275#endif
276
[7729]277#if HARD_DEBUG_LEVEL >= ORX_INFO
[7161]278#define COUT3 \
[7729]279  if (SOFT_DEBUG_LEVEL >= ORX_INFO) \
[7161]280    COUT_EXEC
281#else
[7729]282#define COUT3 if (ORX_NONE) \
[7161]283    COUT_EXEC
284#endif
285
[7729]286#if HARD_DEBUG_LEVEL >= ORX_DEBUG
[7161]287#define COUT4 \
[7729]288  if (SOFT_DEBUG_LEVEL >= ORX_DEBUG) \
[7161]289    COUT_EXEC
290#else
[7729]291#define COUT4 if (ORX_NONE) \
[7161]292    COUT_EXEC
293#endif
294
[7729]295#if HARD_DEBUG_LEVEL >= ORX_vDEBUG
[7161]296#define COUT5 \
[7729]297     if (SOFT_DEBUG_LEVEL >= ORX_vDEBUG) \
[7161]298       COUT_EXEC
299#else
[7729]300#define COUT5 if (ORX_NONE) \
[7161]301    COUT_EXEC
302#endif
303
304
305#else
[7729]306#define COUT(x) if (ORX_NONE) \
[7161]307    COUT_EXEC
308#endif
309
310#define COUT0 \
311  COUT_EXEC
312
313
[3204]314#endif /* _DEBUG_H */
Note: See TracBrowser for help on using the repository browser.