From 0db6bafd8d8b2041feac7d0c98c6e46049a48eb6 Mon Sep 17 00:00:00 2001 From: Helge Norberg Date: Tue, 22 Nov 2016 22:14:42 +0100 Subject: [PATCH] [logging] Made the Linux ThreadId be the actual thread id in the log. --- common/log.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/log.cpp b/common/log.cpp index 1ad6a38f7..b6488739d 100644 --- a/common/log.cpp +++ b/common/log.cpp @@ -23,6 +23,7 @@ #include "log.h" +#include "os/threading.h" #include "except.h" #include "utf.h" @@ -47,7 +48,7 @@ #include #include #include -#include +#include #include #include @@ -121,7 +122,7 @@ void my_formatter(bool print_all_characters, const boost::log::record_view& rec, std::wstringstream pre_message_stream; append_timestamp(pre_message_stream); - thread_id_column.write(pre_message_stream, boost::log::extract("ThreadID", rec).get().native_id()); + thread_id_column.write(pre_message_stream, boost::log::extract("NativeThreadId", rec)); severity_column.write(pre_message_stream, boost::log::extract("Severity", rec)); auto pre_message = pre_message_stream.str(); @@ -145,6 +146,7 @@ namespace internal{ void init() { boost::log::add_common_attributes(); + boost::log::core::get()->add_global_attribute("NativeThreadId", boost::log::attributes::make_function(&get_current_thread_id)); typedef boost::log::sinks::asynchronous_sink stream_sink_type; auto stream_backend = boost::make_shared(); -- 2.39.2