diff options
author | dburgess <dburgess@19bc5d8c-e614-43d4-8b26-e1612bc8e597> | 2011-11-20 00:22:41 +0000 |
---|---|---|
committer | dburgess <dburgess@19bc5d8c-e614-43d4-8b26-e1612bc8e597> | 2011-11-20 00:22:41 +0000 |
commit | 7b2d522c715f0de762d36a03ca2c8cdf07c6ec19 (patch) | |
tree | 717a0e72008b3cd772aef088854052356b03b3cd /CommonLibs/Logger.h | |
parent | c8739b8b71cc5f4e405a21b788bee31086e21478 (diff) |
git-svn-id: http://wush.net/svn/range/software/public/openbts/trunk@2583 19bc5d8c-e614-43d4-8b26-e1612bc8e597
Diffstat (limited to 'CommonLibs/Logger.h')
-rw-r--r-- | CommonLibs/Logger.h | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/CommonLibs/Logger.h b/CommonLibs/Logger.h index b9fd5ea..35101d8 100644 --- a/CommonLibs/Logger.h +++ b/CommonLibs/Logger.h @@ -40,10 +40,18 @@ #define _LOG(level) \ Log(LOG_##level).get() << pthread_self() \ << " " __FILE__ ":" << __LINE__ << ":" << __FUNCTION__ << ": " + +#ifdef NDEBUG +#define LOG(wLevel) \ + if (LOG_##wLevel!=LOG_DEBUG && gGetLoggingLevel(__FILE__)>=LOG_##wLevel) _LOG(wLevel) +#else #define LOG(wLevel) \ if (gGetLoggingLevel(__FILE__)>=LOG_##wLevel) _LOG(wLevel) +#endif + + #define OBJLOG(wLevel) \ - if (gGetLoggingLevel(__FILE__)>=LOG_##wLevel) _LOG(wLevel) << "obj: " << this << ' ' + LOG(wLevel) << "obj: " << this << ' ' #define LOG_ASSERT(x) { if (!(x)) LOG(EMERG) << "assertion " #x " failed"; } assert(x); @@ -66,13 +74,16 @@ class Log { std::ostringstream mStream; ///< This is where we buffer up the log entry. int mPriority; ///< Priority of current repot. + bool mDummyInit; public: Log(int wPriority) - :mPriority(wPriority) + :mPriority(wPriority), mDummyInit(false) { } + Log(const char* name, const char* level=NULL, int facility=LOG_USER); + // Most of the work is in the desctructor. /** The destructor actually generates the log entry. */ ~Log(); |