mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-31 05:30:17 +01:00
logging: make use of journal configurable
This commit is contained in:
parent
1b808d3b25
commit
96a7f3a3ba
7 changed files with 40 additions and 6 deletions
|
|
@ -470,6 +470,18 @@ unmanaged-devices=mac:00:22:68:1c:59:b1;mac:00:1E:65:30:D1:C4;interface-name:eth
|
|||
</simplelist>
|
||||
</para>
|
||||
</varlistentry>
|
||||
<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.
|
||||
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.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
|
|
|||
|
|
@ -8092,6 +8092,7 @@ nm_device_spawn_iface_helper (NMDevice *self)
|
|||
const char *method;
|
||||
GPtrArray *argv;
|
||||
gs_free char *dhcp4_address = NULL;
|
||||
char *logging_backend;
|
||||
|
||||
if (priv->state != NM_DEVICE_STATE_ACTIVATED)
|
||||
return;
|
||||
|
|
@ -8110,6 +8111,17 @@ nm_device_spawn_iface_helper (NMDevice *self)
|
|||
g_ptr_array_add (argv, g_strdup ("--uuid"));
|
||||
g_ptr_array_add (argv, g_strdup (nm_connection_get_uuid (connection)));
|
||||
|
||||
logging_backend = nm_config_get_is_debug (nm_config_get ())
|
||||
? g_strdup ("debug")
|
||||
: nm_config_data_get_value (NM_CONFIG_GET_DATA_ORIG,
|
||||
NM_CONFIG_KEYFILE_GROUP_LOGGING,
|
||||
NM_CONFIG_KEYFILE_KEY_LOGGING_BACKEND,
|
||||
NM_CONFIG_GET_VALUE_STRIP | NM_CONFIG_GET_VALUE_NO_EMPTY);
|
||||
if (logging_backend) {
|
||||
g_ptr_array_add (argv, g_strdup ("--logging-backend"));
|
||||
g_ptr_array_add (argv, logging_backend);
|
||||
}
|
||||
|
||||
dhcp4_address = find_dhcp4_address (self);
|
||||
|
||||
method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP4_CONFIG);
|
||||
|
|
|
|||
|
|
@ -386,7 +386,12 @@ main (int argc, char *argv[])
|
|||
/* Set up unix signal handling - before creating threads, but after daemonizing! */
|
||||
nm_main_utils_setup_signals (main_loop);
|
||||
|
||||
nm_logging_syslog_openlog (nm_config_get_is_debug (config));
|
||||
nm_logging_syslog_openlog (nm_config_get_is_debug (config)
|
||||
? "debug"
|
||||
: nm_config_data_get_value_cached (NM_CONFIG_GET_DATA_ORIG,
|
||||
NM_CONFIG_KEYFILE_GROUP_LOGGING,
|
||||
NM_CONFIG_KEYFILE_KEY_LOGGING_BACKEND,
|
||||
NM_CONFIG_GET_VALUE_STRIP | NM_CONFIG_GET_VALUE_NO_EMPTY));
|
||||
|
||||
nm_log_info (LOGD_CORE, "NetworkManager (version " NM_DIST_VERSION ") is starting...");
|
||||
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ G_BEGIN_DECLS
|
|||
#define NM_CONFIG_KEYFILE_GROUP_IFUPDOWN "ifupdown"
|
||||
#define NM_CONFIG_KEYFILE_GROUP_IFNET "ifnet"
|
||||
|
||||
#define NM_CONFIG_KEYFILE_KEY_LOGGING_BACKEND "backend"
|
||||
#define NM_CONFIG_KEYFILE_KEY_ATOMIC_SECTION_WAS ".was"
|
||||
#define NM_CONFIG_KEYFILE_KEY_IFNET_AUTO_REFRESH "auto_refresh"
|
||||
#define NM_CONFIG_KEYFILE_KEY_IFNET_MANAGED "managed"
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ static struct {
|
|||
char *dhcp4_clientid;
|
||||
char *dhcp4_hostname;
|
||||
char *iid_str;
|
||||
char *logging_backend;
|
||||
char *opt_log_level;
|
||||
char *opt_log_domains;
|
||||
guint32 priority_v4;
|
||||
|
|
@ -294,6 +295,7 @@ do_early_setup (int *argc, char **argv[])
|
|||
{ "priority4", '\0', 0, G_OPTION_ARG_INT64, &priority64_v4, N_("Route priority for IPv4"), N_("0") },
|
||||
{ "priority6", '\0', 0, G_OPTION_ARG_INT64, &priority64_v6, N_("Route priority for IPv6"), N_("1024") },
|
||||
{ "iid", 'e', 0, G_OPTION_ARG_STRING, &global_opt.iid_str, N_("Hex-encoded Interface Identifier"), "" },
|
||||
{ "logging-backend", '\0', 0, G_OPTION_ARG_STRING, &global_opt.logging_backend, N_("The logging backend configuration value. See logging.backend in NetworkManager.conf"), NULL },
|
||||
|
||||
/* Logging/debugging */
|
||||
{ "version", 'V', 0, G_OPTION_ARG_NONE, &global_opt.show_version, N_("Print NetworkManager version and exit"), NULL },
|
||||
|
|
@ -405,7 +407,9 @@ main (int argc, char *argv[])
|
|||
main_loop = g_main_loop_new (NULL, FALSE);
|
||||
setup_signals ();
|
||||
|
||||
nm_logging_syslog_openlog (global_opt.debug);
|
||||
nm_logging_syslog_openlog (global_opt.logging_backend
|
||||
? global_opt.logging_backend
|
||||
: (global_opt.debug ? "debug" : NULL));
|
||||
|
||||
nm_log_info (LOGD_CORE, "nm-iface-helper (version " NM_DIST_VERSION ") is starting...");
|
||||
|
||||
|
|
|
|||
|
|
@ -627,16 +627,16 @@ nm_log_handler (const gchar *log_domain,
|
|||
}
|
||||
|
||||
void
|
||||
nm_logging_syslog_openlog (gboolean debug)
|
||||
nm_logging_syslog_openlog (const char *logging_backend)
|
||||
{
|
||||
if (log_backend != LOG_BACKEND_GLIB)
|
||||
g_return_if_reached ();
|
||||
|
||||
if (debug) {
|
||||
if (g_strcmp0 (logging_backend, "debug") == 0) {
|
||||
log_backend = LOG_BACKEND_SYSLOG;
|
||||
openlog (G_LOG_DOMAIN, LOG_CONS | LOG_PERROR | LOG_PID, LOG_USER);
|
||||
#if SYSTEMD_JOURNAL
|
||||
} else if (TRUE) {
|
||||
} else if (g_strcmp0 (logging_backend, "syslog") != 0) {
|
||||
log_backend = LOG_BACKEND_JOURNAL;
|
||||
|
||||
/* ensure we read a monotonic timestamp. Reading the timestamp the first
|
||||
|
|
|
|||
|
|
@ -163,6 +163,6 @@ gboolean nm_logging_setup (const char *level,
|
|||
const char *domains,
|
||||
char **bad_domains,
|
||||
GError **error);
|
||||
void nm_logging_syslog_openlog (gboolean debug);
|
||||
void nm_logging_syslog_openlog (const char *logging_backend);
|
||||
|
||||
#endif /* __NETWORKMANAGER_LOGGING_H__ */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue