Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/network/src/defs/debug.h @ 6864

Last change on this file since 6864 was 6864, checked in by patrick, 18 years ago

network: assert included

File size: 5.4 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  *  Handles 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*/
24
25#ifndef _DEBUG_H
26#define _DEBUG_H
27
28#include "confincl.h"
29#ifndef NO_SHELL
30 #include "shell_buffer.h"
31#endif /* NO_SHELL */
32
33#include <stdio.h>
34#include <cassert>
35
36// DEFINE ERROR MODES
37#define NO              0
38#define ERR             1
39#define WARN            2
40#define INFO            3
41//#define DEBUG           4
42#define vDEBUG          5
43
44extern int verbose;
45
46//definitions
47#ifndef MODULAR_DEBUG
48 #define HARD_DEBUG_LEVEL DEBUG
49 #define SOFT_DEBUG_LEVEL verbose
50#else /* MODULAR_DEBUG */
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 */
56
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
68
69  // LOADING
70  #define DEBUG_MODULE_LOAD                  2
71  #define DEBUG_MODULE_IMPORTER              2
72
73  // ENGINES
74  #define DEBUG_MODULE_GRAPHICS              2
75  #define DEBUG_MODULE_EVENT                 2
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
80  #define DEBUG_MODULE_COLLISON_DETECTION    2
81  #define DEBUG_MODULE_SPATIAL_SEPARATION    2
82  #define DEBUG_MODULE_GUI                   2
83  #define DEBUG_MODULE_SOUND                 2
84
85  // MISC
86  #define DEBUG_MODULE_TRACK_MANAGER         2
87  #define DEBUG_MODULE_MATH                  2
88
89  #define DEBUG_MODULE_PNODE                 2
90  #define DEBUG_MODULE_WORLD_ENTITY          2
91
92  #define DEBUG_MODULE_WEAPON                2
93
94  #define HARD_DEBUG_LEVEL DEBUG_SPECIAL_MODULE
95
96 #endif /* DEBUG_SPECIAL_MODULE */
97#endif /* MODULAR_DEBUG */
98
99///////////////////////////////////////////////////
100/// PRINTF: prints with filename and linenumber ///
101///////////////////////////////////////////////////
102#define PRINTFNO      PRINTF0
103#define PRINTFERR     PRINTF1
104#define PRINTFWARN    PRINTF2
105#define PRINTFINFO    PRINTF3
106#define PRINTFDEBUG   PRINTF4
107#define PRINTFVDEBUG  PRINTF5
108
109#if DEBUG <= 3
110#define PRINTF(x)        PRINT(x)
111#endif
112#ifndef NO_SHELL
113#define PRINT_EXEC       ShellBuffer::addBufferLineStatic
114#else /* NO_SHELL */
115#define PRINT_EXEC       printf
116#endif
117
118#ifndef PRINTF
119#ifdef DEBUG
120
121#define PRINTF(x) \
122           PRINTF ## x
123
124#if HARD_DEBUG_LEVEL >= ERR
125#define PRINTF1 \
126    if (SOFT_DEBUG_LEVEL >= ERR) \
127      printf("(EE)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC
128#else
129#define PRINTF1 if (NO)
130#endif
131
132#if HARD_DEBUG_LEVEL >= WARN
133#define PRINTF2 \
134     if (SOFT_DEBUG_LEVEL >= WARN) \
135       printf("(WW)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC
136
137#else
138#define PRINTF2 if (NO)
139#endif
140
141#if HARD_DEBUG_LEVEL >= INFO
142#define PRINTF3 \
143     if (SOFT_DEBUG_LEVEL >= INFO) \
144       printf("(II)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC
145#else
146#define PRINTF3 if (NO)
147#endif
148
149#if HARD_DEBUG_LEVEL >= DEBUG
150#define PRINTF4 \
151     if (SOFT_DEBUG_LEVEL >= DEBUG) \
152       printf("(DD)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC
153#else
154#define PRINTF4 if (NO)
155#endif
156
157#if HARD_DEBUG_LEVEL >= vDEBUG
158#define PRINTF5 \
159     if (SOFT_DEBUG_LEVEL >= vDEBUG) \
160       printf("(VD)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC
161#else
162#define PRINTF5 if (NO)
163#endif
164
165#else
166#define PRINTF(x) if (NO)
167#endif
168
169#define PRINTF0 \
170    printf("%s:%d::", __FILE__, __LINE__) && PRINT_EXEC
171#endif
172
173///////////////////////////////////////////////////
174///  PRINT: just prints output as is            ///
175///////////////////////////////////////////////////
176#define PRINTNO      PRINT0
177#define PRINTERR     PRINT1
178#define PRINTWARN    PRINT2
179#define PRINTINFO    PRINT3
180#define PRINTDEBUG   PRINT4
181#define PRINTVDEBUG  PRINT5
182
183#ifdef  DEBUG
184#define PRINT(x) \
185  PRINT ## x
186
187#if HARD_DEBUG_LEVEL >= ERR
188#define PRINT1  \
189  if (SOFT_DEBUG_LEVEL >= ERR)  \
190    PRINT_EXEC
191#else
192#define PRINT1 if (NO)
193#endif
194
195#if HARD_DEBUG_LEVEL >= WARN
196#define PRINT2 \
197  if (SOFT_DEBUG_LEVEL >= WARN) \
198    PRINT_EXEC
199
200#else
201#define PRINT2 if (NO)
202#endif
203
204#if HARD_DEBUG_LEVEL >= INFO
205#define PRINT3 \
206  if (SOFT_DEBUG_LEVEL >= INFO) \
207    PRINT_EXEC
208#else
209#define PRINT3 if (NO)
210#endif
211
212#if HARD_DEBUG_LEVEL >= DEBUG
213#define PRINT4 \
214  if (SOFT_DEBUG_LEVEL >= DEBUG) \
215    PRINT_EXEC
216#else
217#define PRINT4 if (NO)
218#endif
219
220#if HARD_DEBUG_LEVEL >= vDEBUG
221#define PRINT5 \
222     if (SOFT_DEBUG_LEVEL >= vDEBUG) \
223       PRINT_EXEC
224#else
225#define PRINT5 if (NO)
226#endif
227
228
229#else
230#define PRINT(x) if (NO)
231#endif
232
233#define PRINT0 \
234  PRINT_EXEC
235
236#endif /* _DEBUG_H */
Note: See TracBrowser for help on using the repository browser.