From 391c7f9612a9862f699165ab26390d5253807834 Mon Sep 17 00:00:00 2001 From: rfree2monero Date: Thu, 2 Apr 2015 13:58:38 +0200 Subject: [PATCH] Utils: use const, document dbg. Less default debug --- contrib/otshell_utils/utils.cpp | 17 ++++++++- contrib/otshell_utils/utils.hpp | 64 +++++++++++++++++++-------------- 2 files changed, 53 insertions(+), 28 deletions(-) diff --git a/contrib/otshell_utils/utils.cpp b/contrib/otshell_utils/utils.cpp index 3ca84da8..dbdb8bdc 100644 --- a/contrib/otshell_utils/utils.cpp +++ b/contrib/otshell_utils/utils.cpp @@ -46,6 +46,21 @@ namespace nUtils { INJECT_OT_COMMON_USING_NAMESPACE_COMMON_1 // <=== namespaces +// ==================================================================== + +// Numerical values of the debug levels - see hpp +const int _debug_level_nr_dbg3=20; +const int _debug_level_nr_dbg2=30; +const int _debug_level_nr_dbg1=40; +const int _debug_level_nr_info=50; +const int _debug_level_nr_note=60; +const int _debug_level_nr_fact=75; +const int _debug_level_nr_mark=80; +const int _debug_level_nr_warn=90; +const int _debug_level_nr_erro=100; + +// ==================================================================== + myexception::myexception(const char * what) : std::runtime_error(what) { } @@ -277,7 +292,7 @@ cLogger::cLogger() : mStream(NULL), mStreamBrokenDebug(NULL), mIsBroken(true), // before constructor finishes -mLevel(70), +mLevel(_debug_level_nr_warn), mThread2Number_Biggest(0), // the CURRENT biggest value (no thread yet in map) mPid2Number_Biggest(0) { diff --git a/contrib/otshell_utils/utils.hpp b/contrib/otshell_utils/utils.hpp index 6fb0fc5f..297f13ac 100644 --- a/contrib/otshell_utils/utils.hpp +++ b/contrib/otshell_utils/utils.hpp @@ -132,26 +132,36 @@ std::atomic & gLoggerGuardDepth_Get(); // getter for the global singleton o } catch(...) { if (part<8) gCurrentLogger.write_stream(100,CHANNEL)<<"DEBUG-ERROR: problem in debug mechanism e.g. in locking." < & gLoggerGuardDepth_Get(); // getter for the global singleton o nOT::nUtils::gLoggerGuard.unlock(); #define _scope_debug_level(LEVEL,VAR) _scope_debug_level_c("",LEVEL,VAR) -#define _scope_dbg1(VAR) _scope_debug_level( 20,VAR) -#define _scope_dbg2(VAR) _scope_debug_level( 30,VAR) -#define _scope_dbg3(VAR) _scope_debug_level( 40,VAR) // details -#define _scope_info(VAR) _scope_debug_level( 50,VAR) // more boring info -#define _scope_note(VAR) _scope_debug_level( 70,VAR) // info -#define _scope_fact(VAR) _scope_debug_level( 75,VAR) // interesting event -#define _scope_mark(VAR) _scope_debug_level( 80,VAR) // marked action -#define _scope_warn(VAR) _scope_debug_level( 90,VAR) // some problem -#define _scope_erro(VAR) _scope_debug_level( 100,VAR) // error - report +#define _scope_dbg1(VAR) _scope_debug_level( _debug_level_nr_dbg3, VAR) +#define _scope_dbg2(VAR) _scope_debug_level( _debug_level_nr_dbg2, VAR) +#define _scope_dbg3(VAR) _scope_debug_level( _debug_level_nr_dbg1, VAR) +#define _scope_info(VAR) _scope_debug_level( _debug_level_nr_info, VAR) +#define _scope_note(VAR) _scope_debug_level( _debug_level_nr_note, VAR) +#define _scope_fact(VAR) _scope_debug_level( _debug_level_nr_fact, VAR) +#define _scope_mark(VAR) _scope_debug_level( _debug_level_nr_mark, VAR) +#define _scope_warn(VAR) _scope_debug_level( _debug_level_nr_warn, VAR) +#define _scope_erro(VAR) _scope_debug_level( _debug_level_nr_erro, VAR) /*** @brief do not use this namespace directly, it is implementation detail.