diff options
author | Chris Wilson <chris+github@qwirx.com> | 2007-12-04 00:07:45 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2007-12-04 00:07:45 +0000 |
commit | f7b50cc659f5f9db9e2f96a2c4b7a2522602a76c (patch) | |
tree | 19490031a34d9f7fda4d83d80f98aa082195dac1 /lib/common | |
parent | 21598bc69144d139305ee49c6241d1ed411a2b44 (diff) |
Enable TRACE logging in release builds, but make it really cheap
when disabled.
Diffstat (limited to 'lib/common')
-rw-r--r-- | lib/common/Logging.h | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/common/Logging.h b/lib/common/Logging.h index bdc9e8ab..9753fc88 100644 --- a/lib/common/Logging.h +++ b/lib/common/Logging.h @@ -37,11 +37,9 @@ #define BOX_WARNING(stuff) BOX_LOG(Log::WARNING, stuff) #define BOX_NOTICE(stuff) BOX_LOG(Log::NOTICE, stuff) #define BOX_INFO(stuff) BOX_LOG(Log::INFO, stuff) -#if defined NDEBUG && ! defined COMPILE_IN_TRACES - #define BOX_TRACE(stuff) -#else - #define BOX_TRACE(stuff) BOX_LOG(Log::TRACE, stuff) -#endif +#define BOX_TRACE(stuff) \ + if (Logging::IsEnabled(Log::TRACE)) \ + { BOX_LOG(Log::TRACE, stuff) } #define BOX_FORMAT_ACCOUNT(accno) \ std::hex << \ @@ -193,6 +191,10 @@ class Logging static void SetContext(std::string context); static void ClearContext(); static void SetGlobalLevel(Log::Level level) { sGlobalLevel = level; } + static bool IsEnabled(Log::Level level) + { + return (int)sGlobalLevel >= (int)level; + } static void SetProgramName(const std::string& rProgramName); }; |