Commit 6c3cf54b authored by Mihai Moldovan's avatar Mihai Moldovan

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.
parent 1829a35c
......@@ -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() << "] ";
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment