[Box Backup-commit] COMMIT r2417 - box/trunk/lib/common

boxbackup-dev at boxbackup.org boxbackup-dev at boxbackup.org
Tue Dec 30 18:30:41 GMT 2008


Author: chris
Date: 2008-12-30 18:30:41 +0000 (Tue, 30 Dec 2008)
New Revision: 2417

Modified:
   box/trunk/lib/common/Logging.h
Log:
Add a function to return a native error message as a string.


Modified: box/trunk/lib/common/Logging.h
===================================================================
--- box/trunk/lib/common/Logging.h	2008-12-30 18:30:12 UTC (rev 2416)
+++ box/trunk/lib/common/Logging.h	2008-12-30 18:30:41 UTC (rev 2417)
@@ -10,6 +10,7 @@
 #ifndef LOGGING__H
 #define LOGGING__H
 
+#include <cerrno>
 #include <cstring>
 #include <iomanip>
 #include <sstream>
@@ -58,7 +59,18 @@
 #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()))
 	#define BOX_LOG_WIN_WARNING(stuff) \




More information about the Boxbackup-commit mailing list