use fmt::safe_strerror

This commit is contained in:
gabime
2018-06-01 17:06:20 +03:00
parent f2bc1571b4
commit 38b3ecb02e
2 changed files with 14 additions and 53 deletions

View File

@@ -158,7 +158,18 @@ public:
spdlog_ex(const std::string &msg, int last_errno)
{
_msg = msg + ": " + details::os::errno_str(last_errno);
std::string errno_string;
char buf[256], *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;
}
const char *what() const SPDLOG_NOEXCEPT override