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:
parent
7f33081522
commit
06343d3812
8
Logger.h
8
Logger.h
|
@ -43,12 +43,18 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <sys/syscall.h>
|
||||||
|
|
||||||
// We cannot include Utils.h because it includes Logger.h, so just declare timestr() here.
|
// 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.
|
// If timestr decl is changed G++ will whine when Utils.h is included.
|
||||||
namespace Utils { const std::string timestr(); };
|
namespace Utils { const std::string timestr(); };
|
||||||
|
|
||||||
|
#if !defined(gettid)
|
||||||
|
# define gettid() syscall(SYS_gettid)
|
||||||
|
#endif // !defined(gettid)
|
||||||
|
|
||||||
#define _LOG(level) \
|
#define _LOG(level) \
|
||||||
Log(LOG_##level).get() << pthread_self() \
|
Log(LOG_##level).get() << "pid(" << getpid() << "), tid(" << gettid() << ") " \
|
||||||
<< Utils::timestr() << " " __FILE__ ":" << __LINE__ << ":" << __FUNCTION__ << ": "
|
<< 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.
|
// (pat) If you '#define LOG_GROUP groupname' before including Logger.h, then you can set Log.Level.groupname as well as Log.Level.filename.
|
||||||
|
|
|
@ -111,7 +111,7 @@ void SelfDetect::RegisterProgram(const char *argv0)
|
||||||
|
|
||||||
void SelfDetect::Exit(int sig)
|
void SelfDetect::Exit(int sig)
|
||||||
{
|
{
|
||||||
LOG(NOTICE) << "*** Terminating because of signal " << sig;
|
LOG(NOTICE) << "*** Terminating because of signal " << sig;
|
||||||
|
|
||||||
if (mProg == NULL)
|
if (mProg == NULL)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue