37 #define I_BESDebug_h 1 44 #define BESDEBUG( x, y ) 59 #define BESDEBUG( x, y ) do { if( BESDebug::IsSet( x ) ) *(BESDebug::GetStrm()) << "[" << BESDebug::GetPidStr() << "]["<< x << "] " << y ; } while( 0 ) 63 #define BESISDEBUG( x ) (false) 85 #define BESISDEBUG( x ) BESDebug::IsSet( x ) 91 typedef std::map<std::string,bool> DebugMap;
93 static DebugMap _debug_map ;
94 static std::ostream *_debug_strm ;
95 static bool _debug_strm_created ;
97 typedef DebugMap::iterator _debug_iter ;
100 typedef DebugMap::const_iterator debug_citer ;
102 static const DebugMap &debug_map()
117 static void Set(
const std::string &flagName,
bool value)
119 if (flagName ==
"all" && value)
121 _debug_iter i = _debug_map.begin();
122 _debug_iter e = _debug_map.end();
128 _debug_map[flagName] = value;
143 debug_citer a = _debug_map.find(
"all");
144 debug_citer i = _debug_map.find(flagName);
145 if (i == _debug_map.end())
147 if (a == _debug_map.end())
149 _debug_map[flagName] =
false;
153 _debug_map[flagName] =
true;
163 static bool IsSet(
const std::string &flagName)
165 debug_citer i = _debug_map.find(flagName);
166 if (i != _debug_map.end())
169 i = _debug_map.find(
"all");
170 if (i != _debug_map.end())
204 static void SetStrm(std::ostream *strm,
bool created)
206 if (_debug_strm_created && _debug_strm)
208 _debug_strm->flush();
212 else if (_debug_strm)
214 _debug_strm->flush();
218 _debug_strm = &std::cerr;
219 _debug_strm_created =
false;
224 _debug_strm_created = created;
228 static void SetUp(
const std::string &values ) ;
229 static void Help( std::ostream &strm ) ;
230 static bool IsContextName(
const std::string &name ) ;
234 #endif // I_BESDebug_h static std::ostream * GetStrm()
return the debug stream
static void Register(const std::string &flagName)
register the specified debug flag
static std::string GetPidStr()
return the pid as a string
static void SetUp(const std::string &values)
Sets up debugging for the bes.
static void Set(const std::string &flagName, bool value)
set the debug context to the specified value
static std::string GetOptionsString()
static void Help(std::ostream &strm)
Writes help information for so that developers know what can be set for debugging.
static void SetStrm(std::ostream *strm, bool created)
set the debug output stream to the specified stream
static bool IsSet(const std::string &flagName)
see if the debug context flagName is set to true