# HG changeset patch # User Alain Mazy # Date 1784213753 -7200 # Node ID 27fb4cb989856bd7d94d4de13f9dfb8f302c14f4 # Parent d251cd0ec90a4bf401dbf7c78a34c72a679b9b54 --logs-threadnames-in-context diff -r d251cd0ec90a -r 27fb4cb98985 NEWS --- a/NEWS Thu Jul 16 16:00:22 2026 +0200 +++ b/NEWS Thu Jul 16 16:55:53 2026 +0200 @@ -41,6 +41,8 @@ - Some line of log now contain additional contextual informations like the job id they relate to. A new "--logs-no-context" command line option can be used to get back to the previous behavior to keep backward compatibility and reduce the lines length. + Another "--logs-threadnames-in-context" command line option can be used to add more information in the + contexts wrt the thread that has requested a service. This is mainly for developers. * C-Find SCP: - When Orthanc was requested a sequence in a C-Find query, Orthanc was actually not returning any sequences in the C-Find answer if the matched resource did contain the requested sequence and diff -r d251cd0ec90a -r 27fb4cb98985 OrthancFramework/Sources/Logging.cpp --- a/OrthancFramework/Sources/Logging.cpp Thu Jul 16 16:00:22 2026 +0200 +++ b/OrthancFramework/Sources/Logging.cpp Thu Jul 16 16:55:53 2026 +0200 @@ -46,8 +46,6 @@ { 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; @@ -953,6 +951,7 @@ static ThreadsInformations threadsInformations_; static bool enableThreadNames_ = true; static bool enableThreadContexts_ = true; +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 std::list loggingListeners_; static boost::shared_mutex loggingListenersMutex_; @@ -971,6 +970,11 @@ enableThreadContexts_ = enabled; } + void SetThreadNamesInContextsEnabled(bool enabled) + { + logCallerThreadNameInContext_ = enabled; + } + static void GetLogPath(boost::filesystem::path& log, boost::filesystem::path& link, const std::string& suffix, @@ -1129,7 +1133,7 @@ ThreadContextMemento::ScopedSetter::ScopedSetter(const ThreadContextMemento& memento) : count_(0) { - if (logCallerThreadNameInContext && enableThreadNames_ && !memento.pimpl_->threadName_.empty()) + if (logCallerThreadNameInContext_ && enableThreadNames_ && !memento.pimpl_->threadName_.empty()) { PushCurrentThreadContext("from " + memento.pimpl_->threadName_); count_++; diff -r d251cd0ec90a -r 27fb4cb98985 OrthancFramework/Sources/Logging.h --- a/OrthancFramework/Sources/Logging.h Thu Jul 16 16:00:22 2026 +0200 +++ b/OrthancFramework/Sources/Logging.h Thu Jul 16 16:55:53 2026 +0200 @@ -139,6 +139,8 @@ ORTHANC_PUBLIC void SetThreadContextsEnabled(bool enabled); + ORTHANC_PUBLIC void SetThreadNamesInContextsEnabled(bool enabled); + ORTHANC_PUBLIC void SetCurrentThreadName(const std::string& name); ORTHANC_PUBLIC bool HasCurrentThreadName(); diff -r d251cd0ec90a -r 27fb4cb98985 OrthancServer/Sources/main.cpp --- a/OrthancServer/Sources/main.cpp Thu Jul 16 16:00:22 2026 +0200 +++ b/OrthancServer/Sources/main.cpp Thu Jul 16 16:55:53 2026 +0200 @@ -756,6 +756,9 @@ << "\t\t\t(if \"file\" is \"-\", dumps to stdout)" << std::endl << " --errors\t\tprint the supported error codes and exit" << std::endl << " --verbose\t\tbe verbose in logs" << std::endl + << " --logs-no-thread\tto remove thread names from logs" << std::endl + << " --logs-no-context\tto remove contexts from logs" << std::endl + << " --logs-threadnames-in-context\t\tto add caller thread names in logs contexts" << std::endl << " --trace\t\thighest verbosity in logs (for debug)" << std::endl << " --upgrade\t\tallow Orthanc to upgrade the version of the" << std::endl << "\t\t\tdatabase (beware that the database will become" << std::endl @@ -2075,6 +2078,10 @@ { Logging::SetThreadContextsEnabled(false); } + else if (argument == "--logs-threadnames-in-context") + { + Logging::SetThreadNamesInContextsEnabled(true); + } else if (argument == "--trace") { SetGlobalVerbosity(Verbosity_Trace);