Eliminate getpid() calls when logging.
This commit is contained in:
parent
06343d3812
commit
73ef35474f
|
@ -47,6 +47,7 @@ std::list<std::string> alarmsList;
|
|||
void addAlarm(const std::string&);
|
||||
//@}
|
||||
|
||||
pid_t gPid = 0;
|
||||
|
||||
|
||||
// (pat) If Log messages are printed before the classes in this module are inited
|
||||
|
|
6
Logger.h
6
Logger.h
|
@ -44,6 +44,8 @@
|
|||
#include <string>
|
||||
#include <assert.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/unistd.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.
|
||||
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue