CARMA C++
Debug.h
Go to the documentation of this file.
1 #ifndef SZA_UTIL_DEBUG_H
2 #define SZA_UTIL_DEBUG_H
3 
11 #include <iostream>
12 #include "carma/szautil/IoLock.h"
14 #include "carma/szautil/Mutex.h"
15 #include "carma/szautil/TimeVal.h"
16 #include "carma/szautil/Directives.h"
17 
18 #if DIR_DEBUG
19 #define DBPRINT(doprint, level, statement) \
20 if(doprint && sza::util::Debug::debugging(level)) {\
21  sza::util::TimeVal timeVal; \
22  timeVal.setToCurrentTime(); \
23  sza::util::IoLock::lockCout(); \
24  std::cout << timeVal \
25  << ": In " \
26  << __PRETTY_FUNCTION__ << ": "\
27  << statement << std::endl; \
28  sza::util::IoLock::unlockCout(); \
29 }
30 #else
31 #define DBPRINT(doprint, level, statement) {}
32 #endif
33 
34 // Some handy predefines
35 
36 #define DEBUG_CAN sza::util::Debug::DEBUG1
37 #define DEBUG_CALTERT sza::util::Debug::DEBUG2
38 #define DEBUG_SIGNAL sza::util::Debug::DEBUG3
39 #define DEBUG_DELAY sza::util::Debug::DEBUG4
40 
41 #define DEBUG_PMAC sza::util::Debug::DEBUG6
42 #define DEBUG_TRACKER sza::util::Debug::DEBUG7
43 #define DEBUG_IFMOD sza::util::Debug::DEBUG8
44 
45 namespace sza {
46  namespace util {
47 
48  class Debug {
49  public:
50 
51  enum Level {
52  DEBUGNONE = 0x0,
53  DEBUG1 = 0x1,
54  DEBUG2 = 0x2,
55  DEBUG3 = 0x4,
56  DEBUG4 = 0x8,
57  DEBUG5 = 0x10,
58  DEBUG6 = 0x20,
59  DEBUG7 = 0x40,
60  DEBUG8 = 0x80,
61  DEBUG9 = 0x100,
62  DEBUG10 = 0x200,
63  DEBUG11 = 0x400,
64  DEBUG12 = 0x800,
65  DEBUG13 = 0x1000,
66  DEBUG14 = 0x2000,
67  DEBUG15 = 0x4000,
68  DEBUG16 = 0x8000,
69  DEBUG17 = 0x10000,
70  DEBUG18 = 0x20000,
71  DEBUG19 = 0x40000,
72  DEBUG20 = 0x80000,
73  DEBUG21 = 0x100000,
74  DEBUG22 = 0x200000,
75  DEBUG23 = 0x400000,
76  DEBUG24 = 0x800000,
77  DEBUG25 = 0x1000000,
78  DEBUG26 = 0x2000000,
79  DEBUG27 = 0x4000000,
80  DEBUG28 = 0x8000000,
81  DEBUG29 = 0x10000000,
82  DEBUG30 = 0x20000000,
83  DEBUG31 = 0x40000000,
84  DEBUG32 = 0x80000000,
85  DEBUGANY = 0xFFFFFFFF
86  };
87 
91  static void setLevel(Level level);
92 
96  static void setLevel(unsigned int);
97 
101  static void addLevel(Level level);
102 
106  static void remLevel(Level level);
107 
111  static bool debugging(Level level = Debug::DEBUGANY);
112 
113  static void lock();
114  static void unlock();
115 
116  private:
117 
121  static Mutex mutex_;
122 
126  static Level level_;
127 
131  Debug();
132 
133  }; // End class Debug
134 
135  }; // End namespace util
136 }; // End namespace sza
137 
138 #endif // End #ifndef
Tagged: Fri Nov 14 12:39:38 UTC 2003.
Tagged: Sat Mar 27 16:28:13 PST 2004.
Tagged: Sat May 22 07:36:14 PDT 2004.