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 )
90 typedef std::map<std::string, bool> DebugMap;
92 static DebugMap _debug_map;
93 static std::ostream *_debug_strm;
94 static bool _debug_strm_created;
96 typedef DebugMap::iterator _debug_iter;
99 typedef DebugMap::const_iterator debug_citer;
101 static const DebugMap &debug_map()
116 static void Set(
const std::string &flagName,
bool value)
118 if (flagName ==
"all" && value) {
119 _debug_iter i = _debug_map.begin();
120 _debug_iter e = _debug_map.end();
121 for (; i != e; i++) {
125 _debug_map[flagName] = value;
140 debug_citer a = _debug_map.find(
"all");
141 debug_citer i = _debug_map.find(flagName);
142 if (i == _debug_map.end()) {
143 if (a == _debug_map.end()) {
144 _debug_map[flagName] =
false;
147 _debug_map[flagName] =
true;
157 static bool IsSet(
const std::string &flagName)
159 debug_citer i = _debug_map.find(flagName);
160 if (i != _debug_map.end())
163 i = _debug_map.find(
"all");
164 if (i != _debug_map.end())
198 static void SetStrm(std::ostream *strm,
bool created)
200 if (_debug_strm_created && _debug_strm) {
201 _debug_strm->flush();
205 else if (_debug_strm) {
206 _debug_strm->flush();
209 _debug_strm = &std::cerr;
210 _debug_strm_created =
false;
214 _debug_strm_created = created;
218 static void SetUp(
const std::string &values);
219 static void Help(std::ostream &strm);
220 static bool IsContextName(
const std::string &name);
static void SetStrm(std::ostream *strm, bool created)
set the debug output stream to the specified stream
static void SetUp(const std::string &values)
Sets up debugging for the bes.
static std::ostream * GetStrm()
return the debug stream
static void Register(const std::string &flagName)
register the specified debug flag
static bool IsSet(const std::string &flagName)
see if the debug context flagName is set to true
static std::string GetPidStr()
return the pid as a string
static void Help(std::ostream &strm)
Writes help information for so that developers know what can be set for debugging.
static std::string GetOptionsString()
static void Set(const std::string &flagName, bool value)
set the debug context to the specified value