From 378c7789ba70de3be11e9eeb5192558479b6c71f Mon Sep 17 00:00:00 2001 From: gabime Date: Sun, 10 Jun 2018 23:16:00 +0300 Subject: [PATCH] Fixed issue #720 --- include/spdlog/common.h | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/include/spdlog/common.h b/include/spdlog/common.h index 0b3a2e21..1ccd397a 100644 --- a/include/spdlog/common.h +++ b/include/spdlog/common.h @@ -158,18 +158,9 @@ public: spdlog_ex(const std::string &msg, int last_errno) { - std::string errno_string; - char buf[500], *buf_ptr = buf; - - if (fmt::safe_strerror(last_errno, buf_ptr, sizeof(buf)) == 0) - { - errno_string = buf_ptr; - } - else - { - errno_string = "Unknown error"; - } - _msg = msg + ": " + errno_string; + fmt::MemoryWriter writer; + fmt::format_system_error(writer, last_errno, msg); + _msg = writer.str(); } const char *what() const SPDLOG_NOEXCEPT override