From a83a46d60059a063ec953ba15f4cdcc2b3874440 Mon Sep 17 00:00:00 2001 From: j-berman Date: Fri, 7 Nov 2025 16:00:57 -0800 Subject: Fix logging deadlock --- contrib/epee/include/misc_log_ex.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'contrib') diff --git a/contrib/epee/include/misc_log_ex.h b/contrib/epee/include/misc_log_ex.h index 392ec11eb..701f8f102 100644 --- a/contrib/epee/include/misc_log_ex.h +++ b/contrib/epee/include/misc_log_ex.h @@ -30,6 +30,7 @@ #ifdef __cplusplus +#include #include #include "easylogging++.h" @@ -40,9 +41,15 @@ #define MAX_LOG_FILE_SIZE 104850000 // 100 MB - 7600 bytes #define MAX_LOG_FILES 50 +#define LOG_TO_STRING(x) \ + std::stringstream ss; \ + ss << x; \ + const std::string str = ss.str(); + #define MCLOG_TYPE(level, cat, color, type, x) do { \ if (el::Loggers::allowed(level, cat)) { \ - el::base::Writer(level, color, __FILE__, __LINE__, ELPP_FUNC, type).construct(cat) << x; \ + LOG_TO_STRING(x); \ + el::base::Writer(level, color, __FILE__, __LINE__, ELPP_FUNC, type).construct(cat) << str; \ } \ } while (0) @@ -91,7 +98,8 @@ do { \ if (el::Loggers::allowed(level, cat)) { \ init; \ - el::base::Writer(level, color, __FILE__, __LINE__, ELPP_FUNC, type).construct(cat) << x; \ + LOG_TO_STRING(x); \ + el::base::Writer(level, color, __FILE__, __LINE__, ELPP_FUNC, type).construct(cat) << str; \ } \ } while(0) #define MIDEBUG(init, x) IFLOG(el::Level::Debug, MONERO_DEFAULT_LOG_CATEGORY, el::Color::Default, el::base::DispatchAction::NormalLog, init, x) -- cgit v1.2.3