37 #define I_BESDebug_h 1 52 #define BESDEBUG( x, y ) 67 #define BESDEBUG( x, y ) do { if( BESDebug::IsSet( x ) ) *(BESDebug::GetStrm()) << "[" << BESDebug::GetPidStr() << "]["<< x << "] " << y ; } while( 0 ) 90 #define BESISDEBUG( x ) BESDebug::IsSet( x ) 95 typedef map<string,bool> DebugMap;
97 static DebugMap _debug_map ;
98 static ostream *_debug_strm ;
99 static bool _debug_strm_created ;
101 typedef DebugMap::iterator _debug_iter ;
104 typedef DebugMap::const_iterator debug_citer ;
106 static const DebugMap &debug_map()
121 static void Set(
const string &flagName,
bool value)
123 if (flagName ==
"all" && value)
125 _debug_iter i = _debug_map.begin();
126 _debug_iter e = _debug_map.end();
132 _debug_map[flagName] = value;
147 debug_citer a = _debug_map.find(
"all");
148 debug_citer i = _debug_map.find(flagName);
149 if (i == _debug_map.end())
151 if (a == _debug_map.end())
153 _debug_map[flagName] =
false;
157 _debug_map[flagName] =
true;
167 static bool IsSet(
const string &flagName)
169 debug_citer i = _debug_map.find(flagName);
170 if (i != _debug_map.end())
173 i = _debug_map.find(
"all");
174 if (i != _debug_map.end())
208 static void SetStrm(ostream *strm,
bool created)
210 if (_debug_strm_created && _debug_strm)
212 _debug_strm->flush();
216 else if (_debug_strm)
218 _debug_strm->flush();
223 _debug_strm_created =
false;
228 _debug_strm_created = created;
232 static void SetUp(
const string &values ) ;
233 static void Help( ostream &strm ) ;
234 static bool IsContextName(
const string &name ) ;
238 #endif // I_BESDebug_h static void SetUp(const string &values)
Sets up debugging for the bes.
static void Set(const string &flagName, bool value)
set the debug context to the specified value
static string GetPidStr()
return the pid as a string
static void Help(ostream &strm)
Writes help information for so that developers know what can be set for debugging.
static ostream * GetStrm()
return the debug stream
static string GetOptionsString()
static bool IsSet(const string &flagName)
see if the debug context flagName is set to true
static void SetStrm(ostream *strm, bool created)
set the debug output stream to the specified stream
static void Register(const string &flagName)
register the specified debug flag