diff --git a/Logger.h b/Logger.h index 63ae3a7..c16b34a 100644 --- a/Logger.h +++ b/Logger.h @@ -43,12 +43,18 @@ #include #include #include +#include + // 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. diff --git a/SelfDetect.cpp b/SelfDetect.cpp index 9e0e1c5..0870ad5 100644 --- a/SelfDetect.cpp +++ b/SelfDetect.cpp @@ -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) {