aboutsummaryrefslogtreecommitdiff
path: root/nxcomp
diff options
context:
space:
mode:
authorMihai Moldovan <ionic@ionic.de>2017-10-27 08:32:14 +0200
committerMihai Moldovan <ionic@ionic.de>2017-10-27 08:46:39 +0200
commit6c3cf54ba84e9e31a5be62ab58391106d35eaff6 (patch)
tree1def8ff54a75046ae0e7860fcead2559747c1266 /nxcomp
parent1829a35cd0413a752bad082967508ffd8b1c7d01 (diff)
downloadnx-libs-6c3cf54ba84e9e31a5be62ab58391106d35eaff6.tar.gz
nx-libs-6c3cf54ba84e9e31a5be62ab58391106d35eaff6.tar.bz2
nx-libs-6c3cf54ba84e9e31a5be62ab58391106d35eaff6.zip
nxcomp/src/Log.cpp: add PID to thread ID output if requested.
The default function we use (if a thread name is not specified explicitly) is pthread_self(). This function returns a number that is guaranteed to be unique for each thread within a process, but this assertion doesn't hold globally. Hence only using the thread ID is ambiguous when logging from multiple processes.
Diffstat (limited to 'nxcomp')
-rw-r--r--nxcomp/src/Log.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/nxcomp/src/Log.cpp b/nxcomp/src/Log.cpp
index 83e11b98a..951c10a04 100644
--- a/nxcomp/src/Log.cpp
+++ b/nxcomp/src/Log.cpp
@@ -29,6 +29,7 @@
#include <fstream>
#include <sstream>
#include <iomanip>
+#include <unistd.h>
#include "Log.h"
#include "config.h"
@@ -95,7 +96,7 @@ std::string NXLog::stamp_to_string(const NXLogStamp& stamp) const
if ( log_thread_id() )
{
if ( thread_name().empty() )
- oss << pthread_self() << " ";
+ oss << getpid() << "/" << pthread_self() << " ";
else
oss << "[" << thread_name() << "] ";
}