aboutgitcodebugslistschat
path: root/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'log.c')
-rw-r--r--log.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/log.c b/log.c
index 0199eb4..7182acb 100644
--- a/log.c
+++ b/log.c
@@ -78,6 +78,11 @@ void vlogmsg(int pri, const char *format, va_list ap)
}
}
+/**
+ * logmsg() - vlogmsg() wrapper for variable argument lists
+ * @pri: Facility and level map, same as priority for vsyslog()
+ * @format: Message
+ */
void logmsg(int pri, const char *format, ...)
{
va_list ap;
@@ -87,6 +92,23 @@ void logmsg(int pri, const char *format, ...)
va_end(ap);
}
+/**
+ * logmsg_perror() - vlogmsg() wrapper with perror()-like functionality
+ * @pri: Facility and level map, same as priority for vsyslog()
+ * @format: Message
+ */
+void logmsg_perror(int pri, const char *format, ...)
+{
+ int errno_copy = errno;
+ va_list ap;
+
+ va_start(ap, format);
+ vlogmsg(pri, format, ap);
+ va_end(ap);
+
+ logmsg(pri, ": %s", strerror(errno_copy));
+}
+
/* Prefixes for log file messages, indexed by priority */
const char *logfile_prefix[] = {
NULL, NULL, NULL, /* Unused: LOG_EMERG, LOG_ALERT, LOG_CRIT */