aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorj-berman <justinberman@protonmail.com>2025-11-07 16:00:57 -0800
committerj-berman <justinberman@protonmail.com>2025-11-11 10:44:26 -0800
commita83a46d60059a063ec953ba15f4cdcc2b3874440 (patch)
treea152e55dfff1e3b4a84dd83ae8648d15e189a21d /contrib
parent3cc9d65c9374b541e64320052c933184944375ea (diff)
downloadmonzero-core-a83a46d60059a063ec953ba15f4cdcc2b3874440.tar.gz
monzero-core-a83a46d60059a063ec953ba15f4cdcc2b3874440.tar.xz
monzero-core-a83a46d60059a063ec953ba15f4cdcc2b3874440.zip
Fix logging deadlock
Diffstat (limited to 'contrib')
-rw-r--r--contrib/epee/include/misc_log_ex.h12
1 files changed, 10 insertions, 2 deletions
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 <sstream>
#include <string>
#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)