git-svn-id: http://wush.net/svn/range/software/public/openbts/trunk@2583 19bc5d8c-e614-43d4-8b26-e1612bc8e597

This commit is contained in:
dburgess 2011-11-20 00:22:41 +00:00
parent c8739b8b71
commit 7b2d522c71
2 changed files with 21 additions and 2 deletions

View File

@ -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<numLevels);

View File

@ -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();