summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs-xml/smbdotconf/logging/logging.xml1
-rw-r--r--lib/util/debug.c21
-rwxr-xr-xlib/util/wscript_build1
-rw-r--r--lib/util/wscript_configure14
4 files changed, 36 insertions, 1 deletions
diff --git a/docs-xml/smbdotconf/logging/logging.xml b/docs-xml/smbdotconf/logging/logging.xml
index f888c4623e8..039a9656e88 100644
--- a/docs-xml/smbdotconf/logging/logging.xml
+++ b/docs-xml/smbdotconf/logging/logging.xml
@@ -29,6 +29,7 @@
<itemizedlist>
<listitem><para><parameter moreinfo="none">syslog</parameter></para></listitem>
<listitem><para><parameter moreinfo="none">file</parameter></para></listitem>
+ <listitem><para><parameter moreinfo="none">systemd</parameter></para></listitem>
</itemizedlist>
</description>
diff --git a/lib/util/debug.c b/lib/util/debug.c
index 7602a515687..81acbb1b33d 100644
--- a/lib/util/debug.c
+++ b/lib/util/debug.c
@@ -102,7 +102,7 @@ static struct {
.fd = 2 /* stderr by default */
};
-#ifdef WITH_SYSLOG
+#if defined(WITH_SYSLOG) || defined(HAVE_SYSTEMD_JOURNAL)
static int debug_level_to_priority(int level)
{
/*
@@ -174,6 +174,18 @@ static void debug_syslog_log(int msg_level,
}
#endif /* WITH_SYSLOG */
+#ifdef HAVE_SYSTEMD_JOURNAL
+#include <systemd/sd-journal.h>
+static void debug_systemd_log(int msg_level,
+ const char *msg, const char *msg_no_nl)
+{
+ sd_journal_send("MESSAGE=%s", msg_no_nl,
+ "PRIORITY=%d", debug_level_to_priority(msg_level),
+ "LEVEL=%d", msg_level,
+ NULL);
+}
+#endif
+
static struct debug_backend {
const char *name;
int log_level;
@@ -192,6 +204,13 @@ static struct debug_backend {
.log = debug_syslog_log,
},
#endif
+
+#ifdef HAVE_SYSTEMD_JOURNAL
+ {
+ .name = "systemd",
+ .log = debug_systemd_log,
+ },
+#endif
};
static struct debug_backend *debug_find_backend(const char *name)
diff --git a/lib/util/wscript_build b/lib/util/wscript_build
index b2e406ec8e8..5f89c83a20b 100755
--- a/lib/util/wscript_build
+++ b/lib/util/wscript_build
@@ -31,6 +31,7 @@ bld.SAMBA_SUBSYSTEM('close-low-fd',
bld.SAMBA_LIBRARY('samba-debug',
source='debug.c',
deps='replace time-basic close-low-fd talloc socket-blocking',
+ public_deps='systemd-journal',
local_include=False,
private_library=True)
diff --git a/lib/util/wscript_configure b/lib/util/wscript_configure
index 8cf77b432ae..0153fb8f67f 100644
--- a/lib/util/wscript_configure
+++ b/lib/util/wscript_configure
@@ -113,3 +113,17 @@ if (conf.CONFIG_SET('HAVE_SYSTEMD_SD_DAEMON_H') and
else:
conf.SET_TARGET_TYPE('systemd-daemon', 'EMPTY')
conf.undefine('HAVE_SYSTEMD')
+
+if Options.options.enable_systemd != False:
+ conf.check_cfg(package='libsystemd-journal', args='--cflags --libs',
+ msg='Checking for libsystemd-journal',
+ uselib_store="SYSTEMD-JOURNAL")
+ conf.CHECK_HEADERS('systemd/sd-journal.h', lib='systemd-journal')
+ conf.CHECK_LIB('systemd-journal', shlib=True)
+
+if (conf.CONFIG_SET('HAVE_SYSTEMD_SD_JOURNAL_H') and
+ conf.CONFIG_SET('HAVE_LIBSYSTEMD_JOURNAL')):
+ conf.DEFINE('HAVE_SYSTEMD_JOURNAL', '1')
+else:
+ conf.SET_TARGET_TYPE('systemd-journal', 'EMPTY')
+ conf.undefine('HAVE_SYSTEMD_JOURNAL')