git-svn-id: http://wush.net/svn/range/software/public/CommonLibs/trunk@2583 19bc5d8c-e614-43d4-8b26-e1612bc8e597
This commit is contained in:
parent
3059c5a6a1
commit
22c77a7c6a
|
@ -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);
|
||||
|
|
15
Logger.h
15
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();
|
||||
|
|
Loading…
Reference in New Issue