[Box Backup-commit] COMMIT r1972 - box/chris/general/lib/common
boxbackup-dev@fluffy.co.uk
boxbackup-dev@fluffy.co.uk
Sat, 8 Dec 2007 23:05:13 +0000 (UTC)
Author: chris
Date: 2007-12-08 23:05:13 +0000 (Sat, 08 Dec 2007)
New Revision: 1972
Modified:
box/chris/general/lib/common/Logging.h
Log:
Enable TRACE logging in release builds, but make it really cheap
when disabled. (merges [1938])
Modified: box/chris/general/lib/common/Logging.h
===================================================================
--- box/chris/general/lib/common/Logging.h 2007-12-08 23:03:41 UTC (rev 1971)
+++ box/chris/general/lib/common/Logging.h 2007-12-08 23:05:13 UTC (rev 1972)
@@ -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 << \
@@ -191,6 +189,10 @@
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);
};