summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2013-09-05 06:52:15 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-09-18 18:56:40 +0200
commit77c0d1f6074059dafd2293f9c42ea0f9d60f8aad (patch)
tree4a6c5fcc27adb75a0dd84464fbf1ab0ffc183c1c /src/util
parent11a044514e3799c4e685cf98ed5c058aa02b5fdb (diff)
downloadsssd-77c0d1f6074059dafd2293f9c42ea0f9d60f8aad.tar.gz
sssd-77c0d1f6074059dafd2293f9c42ea0f9d60f8aad.tar.bz2
sssd-77c0d1f6074059dafd2293f9c42ea0f9d60f8aad.zip
Add journald support
Diffstat (limited to 'src/util')
-rw-r--r--src/util/sss_log.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/util/sss_log.c b/src/util/sss_log.c
index 45e88310..6b78c9d4 100644
--- a/src/util/sss_log.c
+++ b/src/util/sss_log.c
@@ -23,7 +23,12 @@
*/
#include "util/util.h"
+
+#ifdef WITH_JOURNALD
+#include <systemd/sd-journal.h>
+#else /* WITH_JOURNALD */
#include <syslog.h>
+#endif /* WITH_JOURNALD */
static int sss_to_syslog(int priority)
{
@@ -52,6 +57,34 @@ static int sss_to_syslog(int priority)
}
}
+#ifdef WITH_JOURNALD
+
+void sss_log(int priority, const char *format, ...)
+{
+ va_list ap;
+ int syslog_priority;
+ int ret;
+ char *message;
+
+ va_start(ap, format);
+ ret = vasprintf(&message, format, ap);
+ va_end(ap);
+
+ if (ret == -1) {
+ /* ENOMEM */
+ return;
+ }
+
+ syslog_priority = sss_to_syslog(priority);
+ sd_journal_send("MESSAGE=%s", message,
+ "PRIORITY=%i", syslog_priority,
+ "SYSLOG_FACILITY=%i", LOG_FAC(LOG_DAEMON),
+ "SYSLOG_IDENTIFIER=%s", debug_prg_name,
+ NULL);
+}
+
+#else /* WITH_JOURNALD */
+
void sss_log(int priority, const char *format, ...)
{
va_list ap;
@@ -67,3 +100,5 @@ void sss_log(int priority, const char *format, ...)
closelog();
}
+
+#endif /* WITH_JOURNALD */