From b5e44777e7e579847bcfaa00420caffd70d8df96 Mon Sep 17 00:00:00 2001 From: Pierrick HYMBERT Date: Sat, 24 Feb 2024 21:17:17 +0100 Subject: [PATCH] server: logs ensure value json value does not raised error --- examples/server/utils.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/server/utils.hpp b/examples/server/utils.hpp index 6165d1cac..c1c6a9892 100644 --- a/examples/server/utils.hpp +++ b/examples/server/utils.hpp @@ -169,7 +169,8 @@ static void server_log(const char *level, const char *function, int line, const ss << buf; for (const auto& el : log.items()) { - snprintf(buf, 1024, " %s=%s", el.key().c_str(), el.value().dump().c_str()); + const std::string value = el.value().dump(-1, ' ', false, json::error_handler_t::replace); + snprintf(buf, 1024, " %s=%s", el.key().c_str(), value.c_str()); ss << buf; }