mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 20:45:18 +00:00
Fix journald PRIORITY values
The systemd journal expects log record PRIORITY values to be encoded using the syslog compatible numbering scheme, not libvirt's own native numbering scheme. We must therefore apply a conversion. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> (cherry picked from commit 21d370f0b90e9ff1c9e9c8e454130b6446d7eb89) Conflicts: src/util/virlog.c - whitespace (commit c7c84fa) https://bugzilla.redhat.com/show_bug.cgi?id=1043550
This commit is contained in:
parent
1e016b9c5f
commit
18dfd38f38
@ -1000,7 +1000,22 @@ virLogAddOutputToFile(virLogPriority priority,
|
||||
}
|
||||
|
||||
|
||||
#if HAVE_SYSLOG_H
|
||||
#if HAVE_SYSLOG_H || USE_JOURNALD
|
||||
|
||||
/* Compat in case we build with journald, but no syslog */
|
||||
# ifndef LOG_DEBUG
|
||||
# define LOG_DEBUG 7
|
||||
# endif
|
||||
# ifndef LOG_INFO
|
||||
# define LOG_INFO 6
|
||||
# endif
|
||||
# ifndef LOG_WARNING
|
||||
# define LOG_WARNING 4
|
||||
# endif
|
||||
# ifndef LOG_ERR
|
||||
# define LOG_ERR 3
|
||||
# endif
|
||||
|
||||
static int
|
||||
virLogPrioritySyslog(virLogPriority priority)
|
||||
{
|
||||
@ -1017,8 +1032,10 @@ virLogPrioritySyslog(virLogPriority priority)
|
||||
return LOG_ERR;
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_SYSLOG_H || USE_JOURNALD */
|
||||
|
||||
|
||||
#if HAVE_SYSLOG_H
|
||||
static void
|
||||
virLogOutputToSyslog(virLogSource source ATTRIBUTE_UNUSED,
|
||||
virLogPriority priority,
|
||||
@ -1183,8 +1200,9 @@ virLogOutputToJournald(virLogSource source,
|
||||
state.bufs = iov_bufs;
|
||||
state.bufs_end = iov_bufs + ARRAY_CARDINALITY(iov_bufs);
|
||||
|
||||
journalAddString(&state ,"MESSAGE", rawstr);
|
||||
journalAddInt(&state, "PRIORITY", priority);
|
||||
journalAddString(&state, "MESSAGE", rawstr);
|
||||
journalAddInt(&state, "PRIORITY",
|
||||
virLogPrioritySyslog(priority));
|
||||
journalAddString(&state, "LIBVIRT_SOURCE",
|
||||
virLogSourceTypeToString(source));
|
||||
if (filename)
|
||||
|
Loading…
x
Reference in New Issue
Block a user