
On 09/28/2012 07:08 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
Add support for logging to the systemd journal, using its simple client library. The benefit over syslog is that it accepts structured log data, so the journald can store individual items like code file/line/func separately from the string message. Tools which require structured log data can then query the journal to extract exactly what they desire without resorting to string parsing
While systemd provides a simple client library for logging, it is more convenient for libvirt to directly write its own client code. This lets us build up the iovec's on the stack, avoiding the need to alloc memory when writing log messages.
Changed in v2:
- Add virFormatIntDecimal instead of using snprintf - Add comment about mkostemp - Fix declaration of linestr var to use size of linenr - Wrap in #ifdef __linux__
ACK with one nit:
+# ifdef __linux__
+static void +virLogOutputToJournald(virLogSource source,
+# endif /* __linux__ */ #endif /* HAVE_SYSLOG_H */
#define IS_SPACE(cur) \ @@ -1114,6 +1292,12 @@ virLogParseOutputs(const char *outputs) count++; VIR_FREE(name); VIR_FREE(abspath); + } else if (STREQLEN(cur, "journald", 8)) { + cur += 8; +#if HAVE_SYSLOG_H + if (virLogAddOutputToJournald(prio) == 0)
This will fail to compile on non-Linux systems that have <syslog.h>. Make the condition: #if HAVE_SYSLOG_H && defined __linux__ -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org