45std::string get_debug_log_line_prefix();
47static std::mutex bes_debug_log_mutex;
50#define BESDEBUG( x, y )
66#define BESDEBUG( x, y ) do { std::unique_lock<std::mutex> lck (bes_debug_log_mutex); if( BESDebug::IsSet( x ) ) { *(BESDebug::GetStrm()) << get_debug_log_line_prefix() << "["<< x << "] " << y; } } while( 0 )
68#define BESDEBUG( x, y ) do { if( BESDebug::IsSet( x ) ) *(BESDebug::GetStrm()) << get_debug_log_line_prefix() << "["<< x << "] " << y ; } while( 0 )
74#define BESISDEBUG( x ) (false)
96#define BESISDEBUG( x ) BESDebug::IsSet( x )
101 typedef std::map<std::string, bool> DebugMap;
103 static DebugMap _debug_map;
104 static std::ostream *_debug_strm;
105 static bool _debug_strm_created;
107 typedef DebugMap::iterator _debug_iter;
110 typedef DebugMap::const_iterator debug_citer;
112 static const DebugMap &debug_map()
127 static void Set(
const std::string &flagName,
bool value)
129 if (flagName ==
"all" && value) {
130 _debug_iter i = _debug_map.begin();
131 _debug_iter e = _debug_map.end();
132 for (; i != e; i++) {
136 _debug_map[flagName] = value;
151 debug_citer a = _debug_map.find(
"all");
152 debug_citer i = _debug_map.find(flagName);
153 if (i == _debug_map.end()) {
154 if (a == _debug_map.end()) {
155 _debug_map[flagName] =
false;
158 _debug_map[flagName] =
true;
168 static bool IsSet(
const std::string &flagName)
170 debug_citer i = _debug_map.find(flagName);
171 if (i != _debug_map.end())
174 i = _debug_map.find(
"all");
175 if (i != _debug_map.end())
192 static std::string GetPidStr();
209 static void SetStrm(std::ostream *strm,
bool created)
211 if (_debug_strm_created && _debug_strm) {
212 _debug_strm->flush();
216 else if (_debug_strm) {
217 _debug_strm->flush();
220 _debug_strm = &std::cerr;
221 _debug_strm_created =
false;
225 _debug_strm_created = created;
229 static void SetUp(
const std::string &values);
230 static void Help(std::ostream &strm);
231 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 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::ostream * GetStrm()
return the debug stream
static std::string GetOptionsString()
static void Set(const std::string &flagName, bool value)
set the debug context to the specified value