From 6c3cf54ba84e9e31a5be62ab58391106d35eaff6 Mon Sep 17 00:00:00 2001 From: Mihai Moldovan Date: Fri, 27 Oct 2017 08:32:14 +0200 Subject: 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. --- nxcomp/src/Log.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 #include #include +#include #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() << "] "; } -- cgit v1.2.3