]> git.sesse.net Git - cubemap/blobdiff - log.cpp
Replace all perror() calls with our own log calls.
[cubemap] / log.cpp
diff --git a/log.cpp b/log.cpp
index ba05a64d1fe5236c4dfe370a947254587c56cf37..a4f923644a5b9597febecb038fa8c54c8526a207 100644 (file)
--- a/log.cpp
+++ b/log.cpp
@@ -1,9 +1,11 @@
 #include "log.h"
 
 #include <stdio.h>
+#include <string.h>
 #include <stdarg.h>
 #include <syslog.h>
 #include <assert.h>
+#include <errno.h>
 #include <string>
 #include <vector>
 
@@ -110,3 +112,10 @@ void log(LogLevel log_level, const char *fmt, ...)
                }
        }
 }
+
+void log_perror(const char *msg)
+{
+       char errbuf[4096];
+       strerror_r(errno, errbuf, sizeof(errbuf));
+       log(ERROR, "%s: %s", msg, errbuf);
+}