From d6837823b0a002c9c8afb48caf3eeda5cb73f173 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Tue, 10 Sep 2013 19:16:48 +0200 Subject: BE: Log domain name to journald if available If the SSSD is compiled with journald support, then all sss_log() statements will include a new field called "SSSD_DOMAIN" that includes the domain name. Filtering only messages from the single domain is then as easy as: # journalctl SSSD_DOMAIN=foo.example.com --- src/util/sss_log.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/util/sss_log.c') diff --git a/src/util/sss_log.c b/src/util/sss_log.c index 6b78c9d4b..5be9e7f2b 100644 --- a/src/util/sss_log.c +++ b/src/util/sss_log.c @@ -65,6 +65,7 @@ void sss_log(int priority, const char *format, ...) int syslog_priority; int ret; char *message; + const char *domain; va_start(ap, format); ret = vasprintf(&message, format, ap); @@ -75,8 +76,14 @@ void sss_log(int priority, const char *format, ...) return; } + domain = getenv(SSS_DOM_ENV); + if (domain == NULL) { + domain = ""; + } + syslog_priority = sss_to_syslog(priority); sd_journal_send("MESSAGE=%s", message, + "SSSD_DOMAIN=%s", domain, "PRIORITY=%i", syslog_priority, "SYSLOG_FACILITY=%i", LOG_FAC(LOG_DAEMON), "SYSLOG_IDENTIFIER=%s", debug_prg_name, -- cgit