# HG changeset patch # User Alain Mazy # Date 1783342201 -7200 # Node ID 2452b20f75a896b3345fb2711e68ab79c6d764b9 # Parent 936dd64d8f7b8b10dbaea0c90b75c0f26f6e7594 fix caller threadname: we need the caller threadname, not the receiver threadname diff -r 936dd64d8f7b -r 2452b20f75a8 OrthancFramework/Sources/Logging.cpp --- a/OrthancFramework/Sources/Logging.cpp Mon Jul 06 10:55:46 2026 +0200 +++ b/OrthancFramework/Sources/Logging.cpp Mon Jul 06 14:50:01 2026 +0200 @@ -46,7 +46,7 @@ { 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 bool logCallerThreadNameInContext = true; // 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; @@ -1116,16 +1116,17 @@ struct ThreadContextMemento::PImpl : public boost::noncopyable { std::list context_; + std::string threadName_; }; ThreadContextMemento::ScopedSetter::ScopedSetter(const ThreadContextMemento& memento) : count_(memento.pimpl_->context_.size()) { - if (logCallerThreadNameInContext && enableThreadNames_) + if (logCallerThreadNameInContext && enableThreadNames_ && !memento.pimpl_->threadName_.empty()) { count_++; - PushCurrentThreadContext("from " + GetCurrentThreadName()); + PushCurrentThreadContext("from " + memento.pimpl_->threadName_); } for (std::list::const_iterator it = memento.pimpl_->context_.begin(); it != memento.pimpl_->context_.end(); ++it) @@ -1149,6 +1150,10 @@ { ThreadsInformations::CurrentThreadReader reader(threadsInformations_); reader.CopyContext(pimpl_->context_); + if (reader.HasThreadName()) + { + pimpl_->threadName_ = reader.GetThreadName(); + } }