diff options
-rw-r--r-- | lib/common/Logging.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/common/Logging.h b/lib/common/Logging.h index 3d5ea370..40c94a09 100644 --- a/lib/common/Logging.h +++ b/lib/common/Logging.h @@ -10,6 +10,7 @@ #ifndef LOGGING__H #define LOGGING__H +#include <cerrno> #include <cstring> #include <iomanip> #include <sstream> @@ -58,6 +59,17 @@ #define BOX_LOG_SYS_FATAL(stuff) \ BOX_FATAL(stuff << ": " << std::strerror(errno) << " (" << errno << ")") +inline std::string GetNativeErrorMessage() +{ +#ifdef WIN32 + return GetErrorMessage(GetLastError()); +#else + std::ostringstream _box_log_line; + _box_log_line << std::strerror(errno) << " (" << errno << ")"; + return _box_log_line.str(); +#endif +} + #ifdef WIN32 #define BOX_LOG_WIN_ERROR(stuff) \ BOX_ERROR(stuff << ": " << GetErrorMessage(GetLastError())) |