summaryrefslogtreecommitdiff
path: root/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'log.c')
-rw-r--r--log.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/log.c b/log.c
index a4e585d..2e0aecb 100644
--- a/log.c
+++ b/log.c
@@ -1,6 +1,7 @@
#include "log.h"
#include <stdbool.h>
#include <unistd.h>
+#include <errno.h>
static FILE *log_file = NULL;
@@ -59,6 +60,19 @@ void log_error(const char *fmt, ...) {
va_end(args);
}
+void log_perror(const char *fmt, ...) {
+ int err = errno;
+ va_list args;
+ va_start(args, fmt);
+ char *prefix = va_sprintf(fmt, args);
+ va_end(args);
+ char error[64];
+ *error = '\0';
+ strerror_r(err, error, sizeof error);
+ log_error("%s: %s", prefix, error);
+ free(prefix);
+}
+
void log_warning(const char *fmt, ...) {
va_list args;
va_start(args, fmt);