From 9f52ab2e5407ef9dd12d9976f19812e07adde78b Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Wed, 11 Aug 2021 14:23:36 +0200 Subject: [PATCH] Senty: add threadname to context --- include/Common.h | 2 +- src/Common.cpp | 4 ++-- src/TSentry.cpp | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/Common.h b/include/Common.h index 619aab0..5eaec2e 100644 --- a/include/Common.h +++ b/include/Common.h @@ -73,7 +73,7 @@ private: static inline std::deque mShutdownHandlers {}; }; -std::string ThreadName(); +std::string ThreadName(bool DebugModeOverride = false); void RegisterThread(const std::string str); #define RegisterThreadAuto() RegisterThread(__func__) diff --git a/src/Common.cpp b/src/Common.cpp index 64b7278..dc773d4 100644 --- a/src/Common.cpp +++ b/src/Common.cpp @@ -73,8 +73,8 @@ std::string DeComp(std::string Compressed) { std::map threadNameMap; -std::string ThreadName() { - if (Application::Settings.DebugModeEnabled) { +std::string ThreadName(bool DebugModeOverride) { + if (DebugModeOverride || Application::Settings.DebugModeEnabled) { auto id = std::this_thread::get_id(); if (threadNameMap.find(id) != threadNameMap.end()) { // found diff --git a/src/TSentry.cpp b/src/TSentry.cpp index cacd096..dc84b09 100644 --- a/src/TSentry.cpp +++ b/src/TSentry.cpp @@ -39,6 +39,7 @@ void TSentry::Log(sentry_level_t level, const std::string& logger, const std::st if (!mValid) { return; } + SetContext("threads", { { "thread-name", ThreadName(true) } }); auto Msg = sentry_value_new_message_event(level, logger.c_str(), text.c_str()); sentry_capture_event(Msg); sentry_remove_transaction();