git-svn-id: http://wush.net/svn/range/software/public/openbts/trunk@2583 19bc5d8c-e614-43d4-8b26-e1612bc8e597
This commit is contained in:
parent
c8739b8b71
commit
7b2d522c71
|
@ -150,6 +150,7 @@ void addAlarm(const string& s)
|
||||||
|
|
||||||
Log::~Log()
|
Log::~Log()
|
||||||
{
|
{
|
||||||
|
if (mDummyInit) return;
|
||||||
// Anything at or above LOG_CRIT is an "alarm".
|
// Anything at or above LOG_CRIT is an "alarm".
|
||||||
// Save alarms in the local list and echo them to stderr.
|
// Save alarms in the local list and echo them to stderr.
|
||||||
if (mPriority <= LOG_CRIT) {
|
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()
|
ostringstream& Log::get()
|
||||||
{
|
{
|
||||||
assert(mPriority<numLevels);
|
assert(mPriority<numLevels);
|
||||||
|
|
|
@ -40,10 +40,18 @@
|
||||||
#define _LOG(level) \
|
#define _LOG(level) \
|
||||||
Log(LOG_##level).get() << pthread_self() \
|
Log(LOG_##level).get() << pthread_self() \
|
||||||
<< " " __FILE__ ":" << __LINE__ << ":" << __FUNCTION__ << ": "
|
<< " " __FILE__ ":" << __LINE__ << ":" << __FUNCTION__ << ": "
|
||||||
|
|
||||||
|
#ifdef NDEBUG
|
||||||
|
#define LOG(wLevel) \
|
||||||
|
if (LOG_##wLevel!=LOG_DEBUG && gGetLoggingLevel(__FILE__)>=LOG_##wLevel) _LOG(wLevel)
|
||||||
|
#else
|
||||||
#define LOG(wLevel) \
|
#define LOG(wLevel) \
|
||||||
if (gGetLoggingLevel(__FILE__)>=LOG_##wLevel) _LOG(wLevel)
|
if (gGetLoggingLevel(__FILE__)>=LOG_##wLevel) _LOG(wLevel)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define OBJLOG(wLevel) \
|
#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);
|
#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.
|
std::ostringstream mStream; ///< This is where we buffer up the log entry.
|
||||||
int mPriority; ///< Priority of current repot.
|
int mPriority; ///< Priority of current repot.
|
||||||
|
bool mDummyInit;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Log(int wPriority)
|
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.
|
// Most of the work is in the desctructor.
|
||||||
/** The destructor actually generates the log entry. */
|
/** The destructor actually generates the log entry. */
|
||||||
~Log();
|
~Log();
|
||||||
|
|
Loading…
Reference in New Issue