37 #define I_BESDebug_h 1
44 std::string get_debug_log_line_prefix();
47 #define BESDEBUG( x, y )
62 #define BESDEBUG( x, y ) do { if( BESDebug::IsSet( x ) ) *(BESDebug::GetStrm()) << get_debug_log_line_prefix() << "["<< x << "] " << y ; } while( 0 )
66 #define BESISDEBUG( x ) (false)
88 #define BESISDEBUG( x ) BESDebug::IsSet( x )
93 typedef std::map<std::string, bool> DebugMap;
95 static DebugMap _debug_map;
96 static std::ostream *_debug_strm;
97 static bool _debug_strm_created;
99 typedef DebugMap::iterator _debug_iter;
102 typedef DebugMap::const_iterator debug_citer;
104 static const DebugMap &debug_map()
119 static void Set(
const std::string &flagName,
bool value)
121 if (flagName ==
"all" && value) {
122 _debug_iter i = _debug_map.begin();
123 _debug_iter e = _debug_map.end();
124 for (; i != e; i++) {
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()) {
146 if (a == _debug_map.end()) {
147 _debug_map[flagName] =
false;
150 _debug_map[flagName] =
true;
160 static bool IsSet(
const std::string &flagName)
162 debug_citer i = _debug_map.find(flagName);
163 if (i != _debug_map.end())
166 i = _debug_map.find(
"all");
167 if (i != _debug_map.end())
184 static std::string GetPidStr();
201 static void SetStrm(std::ostream *strm,
bool created)
203 if (_debug_strm_created && _debug_strm) {
204 _debug_strm->flush();
208 else if (_debug_strm) {
209 _debug_strm->flush();
212 _debug_strm = &std::cerr;
213 _debug_strm_created =
false;
217 _debug_strm_created = created;
221 static void SetUp(
const std::string &values);
222 static void Help(std::ostream &strm);
223 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 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