On 09/28/2012 07:08 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange(a)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.
+
+ if (strchr(rawstr, '\n')) {
+ uint64_t nstr;
+ /* If 'str' containes a newline, then we must
+ * encode the string length, since we can't
+ * rely on the newline for the field separator
+ */
+ IOVEC_SET_STRING(iov[niov++], "MESSAGE\n");
+ nstr = htole64(strlen(rawstr));
+ if ((buffd = mkostemp(path, O_CLOEXEC|O_RDWR)) < 0)
+ return;
It turns out that RHEL 5 glibc is too old to have either htole64 or
mkostemp. Gnulib has mkostemp, and I could add htole64 to gnulib easily
enough. But when you realize that this will only ever work on systems
with systemd, and that RHEL 5 lacks systemd, the easier fix is to just
disable compilation of systemd logging on RHEL 5. Patch coming up.
--
Eric Blake eblake(a)redhat.com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org