37 #define I_BESDebug_h 1 64 #define BESDEBUG( x, y ) do { if( BESDebug::IsSet( x ) ) *(BESDebug::GetStrm()) << "[" << BESDebug::GetPidStr() << "] " << y ; } while( 0 ) 83 #define BESISDEBUG( x ) BESDebug::IsSet( x ) 88 static map<string,bool> _debug_map ;
89 static ostream * _debug_strm ;
90 static bool _debug_strm_created ;
91 typedef map<string,bool>::const_iterator _debug_citer ;
92 typedef map<string,bool>::iterator _debug_iter ;
104 static void Set(
const string &flagName,
bool value )
106 if( flagName ==
"all" && value )
108 _debug_iter i = _debug_map.begin() ;
109 _debug_iter e = _debug_map.end() ;
115 _debug_map[flagName] = value ;
126 _debug_citer a = _debug_map.find(
"all" ) ;
127 _debug_citer i = _debug_map.find( flagName ) ;
128 if( i == _debug_map.end() )
130 if( a == _debug_map.end() )
132 _debug_map[flagName] = false ;
136 _debug_map[flagName] = true ;
145 static bool IsSet(
const string &flagName )
147 _debug_citer i = _debug_map.find( flagName ) ;
148 if( i != _debug_map.end() )
151 i = _debug_map.find(
"all" ) ;
152 if( i != _debug_map.end() )
185 static void SetStrm( ostream *strm,
bool created )
187 if( _debug_strm_created && _debug_strm )
189 _debug_strm->flush();
193 else if( _debug_strm )
195 _debug_strm->flush() ;
199 _debug_strm = &cerr ;
200 _debug_strm_created = false ;
205 _debug_strm_created = created ;
208 static void SetUp(
const string &values ) ;
209 static void Help( ostream &strm ) ;
212 #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 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