From 7b2d522c715f0de762d36a03ca2c8cdf07c6ec19 Mon Sep 17 00:00:00 2001 From: dburgess Date: Sun, 20 Nov 2011 00:22:41 +0000 Subject: git-svn-id: http://wush.net/svn/range/software/public/openbts/trunk@2583 19bc5d8c-e614-43d4-8b26-e1612bc8e597 --- CommonLibs/Logger.cpp | 8 ++++++++ CommonLibs/Logger.h | 15 +++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) (limited to 'CommonLibs') diff --git a/CommonLibs/Logger.cpp b/CommonLibs/Logger.cpp index 57d2bff..d8bfc6e 100644 --- a/CommonLibs/Logger.cpp +++ b/CommonLibs/Logger.cpp @@ -150,6 +150,7 @@ void addAlarm(const string& s) Log::~Log() { + if (mDummyInit) return; // Anything at or above LOG_CRIT is an "alarm". // Save alarms in the local list and echo them to stderr. if (mPriority <= LOG_CRIT) { @@ -162,6 +163,13 @@ Log::~Log() } +Log::Log(const char* name, const char* level, int facility) +{ + mDummyInit = true; + gLogInit(name, level, facility); +} + + ostringstream& Log::get() { assert(mPriority=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(); -- cgit v1.2.3