mirror of
https://github.com/samba-team/samba.git
synced 2025-02-28 01:58:17 +03:00
debug: Add systemd backend
Signed-off-by: Christof Schmitt <cs@samba.org> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
parent
409b5433d2
commit
4aaf270ea8
@ -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>
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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')
|
||||
|
Loading…
x
Reference in New Issue
Block a user