diff --git a/Logger.cpp b/Logger.cpp index 8363102..05bbfeb 100644 --- a/Logger.cpp +++ b/Logger.cpp @@ -47,6 +47,7 @@ std::list alarmsList; void addAlarm(const std::string&); //@} +pid_t gPid = 0; // (pat) If Log messages are printed before the classes in this module are inited diff --git a/Logger.h b/Logger.h index c16b34a..a30ac96 100644 --- a/Logger.h +++ b/Logger.h @@ -44,6 +44,8 @@ #include #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. @@ -53,8 +55,10 @@ namespace Utils { const std::string timestr(); }; # define gettid() syscall(SYS_gettid) #endif // !defined(gettid) +extern pid_t gPid; + #define _LOG(level) \ - Log(LOG_##level).get() << "pid(" << getpid() << "), tid(" << gettid() << ") " \ + Log(LOG_##level).get() << "pid(" << gPid << "), 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.