Changed logger to use getpid() and gettid() instead of pthread_self(), as

pthread_self() just returns a pointer to an opaque data structure used by
pthreads, and the other two give information that is useful to relate to top,
ps, etc.
Accidently changed indent in SelfDetect::Exit(). Sorry Michael.
Found as a result of working through bug 1608.
This commit is contained in:
dgotwisner 2014-03-31 12:02:24 +02:00 committed by Michael Iedema
parent 7f33081522
commit 06343d3812
2 changed files with 8 additions and 2 deletions

View File

@ -43,12 +43,18 @@
#include <map>
#include <string>
#include <assert.h>
#include <sys/syscall.h>
// We cannot include Utils.h because it includes Logger.h, so just declare timestr() here.
// If timestr decl is changed G++ will whine when Utils.h is included.
namespace Utils { const std::string timestr(); };
#if !defined(gettid)
# define gettid() syscall(SYS_gettid)
#endif // !defined(gettid)
#define _LOG(level) \
Log(LOG_##level).get() << pthread_self() \
Log(LOG_##level).get() << "pid(" << getpid() << "), tid(" << gettid() << ") " \
<< Utils::timestr() << " " __FILE__ ":" << __LINE__ << ":" << __FUNCTION__ << ": "
// (pat) If you '#define LOG_GROUP groupname' before including Logger.h, then you can set Log.Level.groupname as well as Log.Level.filename.

View File

@ -111,7 +111,7 @@ void SelfDetect::RegisterProgram(const char *argv0)
void SelfDetect::Exit(int sig)
{
LOG(NOTICE) << "*** Terminating because of signal " << sig;
LOG(NOTICE) << "*** Terminating because of signal " << sig;
if (mProg == NULL)
{