changeset 6995:0865c7118efa streaming

fix caller thread name in context
author Alain Mazy <am@orthanc.team>
date Mon, 06 Jul 2026 10:29:00 +0200
parents f8b713a8f9b4
children 64a0500e449f
files OrthancFramework/Sources/Logging.cpp
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/Logging.cpp	Tue Jun 30 11:02:55 2026 +0200
+++ b/OrthancFramework/Sources/Logging.cpp	Mon Jul 06 10:29:00 2026 +0200
@@ -46,6 +46,8 @@
 {
   namespace Logging
   {
+    static bool logCallerThreadNameInContext = false; // add a "from THREADNAME" in the context everytime the context is copied from a thread to the other to help track the runnable/callable journey
+
     static const uint32_t ALL_CATEGORIES_MASK = 0xffffffff;
     
     static uint32_t infoCategoriesMask_ = 0;
@@ -1120,12 +1122,10 @@
     ThreadContextMemento::ScopedSetter::ScopedSetter(const ThreadContextMemento& memento) :
       count_(memento.pimpl_->context_.size())
     {
-      if (false) // additional debug information: add the caller thread name
+      if (logCallerThreadNameInContext && enableThreadNames_)
       {
-        if (enableThreadNames_)
-        {
-          PushCurrentThreadContext("from " + GetCurrentThreadName());
-        }
+        count_++;
+        PushCurrentThreadContext("from " + GetCurrentThreadName());
       }
 
       for (std::list<std::string>::const_iterator it = memento.pimpl_->context_.begin(); it != memento.pimpl_->context_.end(); ++it)