From 69f20bdf41726fad5ad7013acd74b82f165036f2 Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Tue, 3 Nov 2020 09:36:00 +0100 Subject: [PATCH] Add TID debug printing --- include/Logger.h | 2 ++ src/logger.cpp | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/include/Logger.h b/include/Logger.h index cf26ba5..f3a4ea7 100644 --- a/include/Logger.h +++ b/include/Logger.h @@ -5,6 +5,8 @@ #include #include void InitLog(); +#define DebugPrintTID(what) DebugPrintTIDInternal(what, __func__) +void DebugPrintTIDInternal(const std::string& what, const std::string& func); // prints the current thread id in debug mode, to make tracing of crashes and asserts easier void ConsoleOut(const std::string& msg); void except(const std::string& toPrint); void debug(const std::string& toPrint); diff --git a/src/logger.cpp b/src/logger.cpp index 72020df..2e3f3fd 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -8,6 +8,13 @@ #include #include #include +#include + +void DebugPrintTIDInternal(const std::string& what, const std::string& func) { + std::stringstream ss; + ss << "Thread '" << std::this_thread::get_id() << "' in " << func << " is " << what; + debug(ss.str()); +} std::string getDate() { typedef std::chrono::duration>::type> days;