fgms 0.11.8
The
FlightGear MultiPlayer Server
project
debug.cxx
Go to the documentation of this file.
1 //
2 // This program is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU General Public License as
4 // published by the Free Software Foundation; either version 2 of the
5 // License, or (at your option) any later version.
6 //
7 // This program is distributed in the hope that it will be useful, but
8 // WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // General Public License for more details.
11 //
12 // You should have received a copy of the GNU General Public License
13 // along with this program; if not, write to the Free Software
14 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, U$
15 //
16 // Copyright (C) 2011 Oliver Schroeder
17 //
18 
19 #ifdef HAVE_CONFIG_H
20 #include "config.h"
21 #endif
22 
23 #include <iostream>
24 #include <string>
25 #include "debug.hxx"
26 
27 using namespace std;
28 
29 // #define DEBUG_TRACE
30 
31 std::string space ( int n )
32 {
33  std::string r;
34  for (int i=0; i<n; i++)
35  r += " ";
36  return (r);
37 }
38 
39 int DEBUG::depth = 0;
40 
41 DEBUG::DEBUG ( const char* function, const char* filename, const int line )
42 {
43  #ifdef DEBUG_TRACE
44  this->filename = filename;
45  this->function = function;
46  this->line = line;
47  cerr << space(depth) << filename << ":" << function << ":" << line << " start" << endl;
48  depth += 2;
49  #endif
50 }
51 
52 void DEBUG::trace ( const char* function, const char* filename, const int line )
53 {
54  #ifdef DEBUG_TRACE
55  cerr << space(depth) << "# TRACE: " << filename << ":" << function << ":" << line << endl;
56  #endif
57 }
58 
60 {
61  #ifdef DEBUG_TRACE
62  depth -= 2;
63  cerr << space(depth) << filename << ":" << function << ":" << line << " end" << endl;
64  #endif
65 }
std::string space(int n)
Definition: debug.cxx:31
~DEBUG()
Definition: debug.cxx:59
DEBUG(const char *function, const char *filename, const int line)
Definition: debug.cxx:41
static int depth
Definition: debug.hxx:38
void trace(const char *function, const char *filename, const int line)
Definition: debug.cxx:52