mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-05 06:30:33 +01:00
logging: add "journal-syslog-style" logging backend to log the old format
This mode logs the same message line as we do for "syslog".
This commit is contained in:
parent
96a7f3a3ba
commit
533a08359e
2 changed files with 22 additions and 8 deletions
|
|
@ -473,13 +473,16 @@ unmanaged-devices=mac:00:22:68:1c:59:b1;mac:00:1E:65:30:D1:C4;interface-name:eth
|
|||
<varlistentry>
|
||||
<term><varname>backend</varname></term>
|
||||
<listitem><para>The logging backend. Supported values
|
||||
are "<literal>debug</literal>", "<literal>syslog</literal>" and
|
||||
"<literal>journal</literal>". "<literal>debug</literal>" uses syslog
|
||||
and logs to standard error.
|
||||
are "<literal>debug</literal>", "<literal>syslog</literal>",
|
||||
"<literal>journal</literal>" and "<literal>journal-syslog-style</literal>.
|
||||
"<literal>debug</literal>" uses syslog and logs to standard error.
|
||||
"<literal>journal-syslog-style</literal>" prints the same message to journal
|
||||
as it would print for "<literal>syslog</literal>", containing redudant
|
||||
fields in the text.
|
||||
If NetworkManager is started in debug mode (<literal>--debug</literal>)
|
||||
this option is ignored and we always use "<literal>debug</literal>".
|
||||
Otherwise, the default is "<literal>journal</literal>" if NetworkManager
|
||||
was compiled with systemd journal support.
|
||||
this option is ignored and "<literal>debug</literal>" is always used.
|
||||
Otherwise, the default is "<literal>journal-syslog-style</literal>" if
|
||||
NetworkManager was compiled with systemd journal support.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ enum {
|
|||
LOG_BACKEND_GLIB,
|
||||
LOG_BACKEND_SYSLOG,
|
||||
LOG_BACKEND_JOURNAL,
|
||||
LOG_BACKEND_JOURNAL_SYSLOG_STYLE,
|
||||
} log_backend = LOG_BACKEND_GLIB;
|
||||
static char *logging_domains_to_string;
|
||||
|
||||
|
|
@ -470,6 +471,7 @@ _nm_log_impl (const char *file,
|
|||
switch (log_backend) {
|
||||
#if SYSTEMD_JOURNAL
|
||||
case LOG_BACKEND_JOURNAL:
|
||||
case LOG_BACKEND_JOURNAL_SYSLOG_STYLE:
|
||||
{
|
||||
gint64 now, boottime;
|
||||
#define _NUM_MAX_FIELDS_SYSLOG_FACILITY 10
|
||||
|
|
@ -482,7 +484,12 @@ _nm_log_impl (const char *file,
|
|||
boottime = nm_utils_monotonic_timestamp_as_boottime (now, 1);
|
||||
|
||||
_iovec_set_format (iov, iov_free, i_field++, "PRIORITY=%d", syslog_level);
|
||||
_iovec_set_format (iov, iov_free, i_field++, "MESSAGE=%-7s %s", level_str, msg);
|
||||
if ( log_backend == LOG_BACKEND_JOURNAL_SYSLOG_STYLE
|
||||
&& full_details) {
|
||||
g_get_current_time (&tv);
|
||||
_iovec_set_format (iov, iov_free, i_field++, "MESSAGE=%-7s [%ld.%06ld] [%s:%u] %s(): %s", level_str, tv.tv_sec, tv.tv_usec, file, line, func, msg);
|
||||
} else
|
||||
_iovec_set_format (iov, iov_free, i_field++, "MESSAGE=%-7s %s", level_str, msg);
|
||||
_iovec_set_literal_string (iov, iov_free, i_field++, "SYSLOG_IDENTIFIER=" G_LOG_DOMAIN);
|
||||
_iovec_set_format (iov, iov_free, i_field++, "SYSLOG_PID=%ld", (long) getpid ());
|
||||
{
|
||||
|
|
@ -601,6 +608,7 @@ nm_log_handler (const gchar *log_domain,
|
|||
switch (log_backend) {
|
||||
#if SYSTEMD_JOURNAL
|
||||
case LOG_BACKEND_JOURNAL:
|
||||
case LOG_BACKEND_JOURNAL_SYSLOG_STYLE:
|
||||
{
|
||||
gint64 now, boottime;
|
||||
|
||||
|
|
@ -637,7 +645,10 @@ nm_logging_syslog_openlog (const char *logging_backend)
|
|||
openlog (G_LOG_DOMAIN, LOG_CONS | LOG_PERROR | LOG_PID, LOG_USER);
|
||||
#if SYSTEMD_JOURNAL
|
||||
} else if (g_strcmp0 (logging_backend, "syslog") != 0) {
|
||||
log_backend = LOG_BACKEND_JOURNAL;
|
||||
if (g_strcmp0 (logging_backend, "journal-syslog-style") != 0)
|
||||
log_backend = LOG_BACKEND_JOURNAL;
|
||||
else
|
||||
log_backend = LOG_BACKEND_JOURNAL_SYSLOG_STYLE;
|
||||
|
||||
/* ensure we read a monotonic timestamp. Reading the timestamp the first
|
||||
* time causes a logging message. We don't want to do that during _nm_log_impl. */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue