diff options
author | Thomas Haller <thaller@redhat.com> | 2015-07-08 19:39:00 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-07-12 14:49:00 +0200 |
commit | 57cc454e213076ee0c0578d1a46f0827595cd77e (patch) | |
tree | c5f7cd17b0b64ef9969abed52783885e70187e29 | |
parent | bc3bf85c2a6311dc7858c13c86e2d10fa65b815d (diff) | |
download | NetworkManager-57cc454e213076ee0c0578d1a46f0827595cd77e.tar.gz |
config: move debug command line option to NMConfig
Whether NM runs in debug mode is also interesting to other
components outside of "main.c". Expose global_opt.debug
via a new nm_config_get_is_debug() function.
Actually, we should move parsing of all command line options
to NMConfig, as NMConfig is the central instance to provide
such information.
-rw-r--r-- | src/main.c | 6 | ||||
-rw-r--r-- | src/nm-config.c | 10 | ||||
-rw-r--r-- | src/nm-config.h | 1 |
3 files changed, 13 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c index 65ba7a61d7..ad44471df6 100644 --- a/src/main.c +++ b/src/main.c @@ -70,7 +70,6 @@ static gboolean configure_and_quit = FALSE; static struct { gboolean show_version; gboolean become_daemon; - gboolean debug; gboolean g_fatal_warnings; gboolean run_from_build_dir; char *opt_log_level; @@ -231,7 +230,6 @@ do_early_setup (int *argc, char **argv[], NMConfigCmdLineOptions *config_cli) GOptionEntry options[] = { { "version", 'V', 0, G_OPTION_ARG_NONE, &global_opt.show_version, N_("Print NetworkManager version and exit"), NULL }, { "no-daemon", 'n', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &global_opt.become_daemon, N_("Don't become a daemon"), NULL }, - { "debug", 'd', 0, G_OPTION_ARG_NONE, &global_opt.debug, N_("Don't become a daemon, and log to stderr"), NULL }, { "log-level", 0, 0, G_OPTION_ARG_STRING, &global_opt.opt_log_level, N_("Log level: one of [%s]"), "INFO" }, { "log-domains", 0, 0, G_OPTION_ARG_STRING, &global_opt.opt_log_domains, N_("Log domains separated by ',': any combination of [%s]"), @@ -372,7 +370,7 @@ main (int argc, char *argv[]) } } - if (global_opt.become_daemon && !global_opt.debug) { + if (global_opt.become_daemon && !nm_config_get_is_debug (config)) { if (daemon (0, 0) < 0) { int saved_errno; @@ -388,7 +386,7 @@ 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 (global_opt.debug); + nm_logging_syslog_openlog (nm_config_get_is_debug (config)); nm_log_info (LOGD_CORE, "NetworkManager (version " NM_DIST_VERSION ") is starting..."); diff --git a/src/nm-config.c b/src/nm-config.c index 215595c208..5b83fb4940 100644 --- a/src/nm-config.c +++ b/src/nm-config.c @@ -53,6 +53,7 @@ struct NMConfigCmdLineOptions { char *no_auto_default_file; char *plugins; gboolean configure_and_quit; + gboolean is_debug; char *connectivity_uri; /* We store interval as signed internally to track whether it's @@ -318,6 +319,12 @@ nm_config_get_configure_and_quit (NMConfig *config) return NM_CONFIG_GET_PRIVATE (config)->configure_and_quit; } +gboolean +nm_config_get_is_debug (NMConfig *config) +{ + return NM_CONFIG_GET_PRIVATE (config)->cli.is_debug; +} + /************************************************************************/ static char ** @@ -432,6 +439,7 @@ _nm_config_cmd_line_options_clear (NMConfigCmdLineOptions *cli) g_clear_pointer (&cli->intern_config_file, g_free); g_clear_pointer (&cli->plugins, g_free); cli->configure_and_quit = FALSE; + cli->is_debug = FALSE; g_clear_pointer (&cli->connectivity_uri, g_free); g_clear_pointer (&cli->connectivity_response, g_free); cli->connectivity_interval = -1; @@ -452,6 +460,7 @@ _nm_config_cmd_line_options_copy (const NMConfigCmdLineOptions *cli, NMConfigCmd dst->intern_config_file = g_strdup (cli->intern_config_file); dst->plugins = g_strdup (cli->plugins); dst->configure_and_quit = cli->configure_and_quit; + dst->is_debug = cli->is_debug; dst->connectivity_uri = g_strdup (cli->connectivity_uri); dst->connectivity_response = g_strdup (cli->connectivity_response); dst->connectivity_interval = cli->connectivity_interval; @@ -491,6 +500,7 @@ nm_config_cmd_line_options_add_to_entries (NMConfigCmdLineOptions *cli, { "no-auto-default", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_FILENAME, &cli->no_auto_default_file, N_("State file for no-auto-default devices"), N_(DEFAULT_NO_AUTO_DEFAULT_FILE) }, { "plugins", 0, 0, G_OPTION_ARG_STRING, &cli->plugins, N_("List of plugins separated by ','"), N_(CONFIG_PLUGINS_DEFAULT) }, { "configure-and-quit", 0, 0, G_OPTION_ARG_NONE, &cli->configure_and_quit, N_("Quit after initial configuration"), NULL }, + { "debug", 'd', 0, G_OPTION_ARG_NONE, &cli->is_debug, N_("Don't become a daemon, and log to stderr"), NULL }, /* These three are hidden for now, and should eventually just go away. */ { "connectivity-uri", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING, &cli->connectivity_uri, N_("An http(s) address for checking internet connectivity"), "http://example.com" }, diff --git a/src/nm-config.h b/src/nm-config.h index 3caf0c5c31..113664e79e 100644 --- a/src/nm-config.h +++ b/src/nm-config.h @@ -102,6 +102,7 @@ const char *nm_config_get_log_level (NMConfig *config); const char *nm_config_get_log_domains (NMConfig *config); const char *nm_config_get_debug (NMConfig *config); gboolean nm_config_get_configure_and_quit (NMConfig *config); +gboolean nm_config_get_is_debug (NMConfig *config); void nm_config_set_values (NMConfig *self, GKeyFile *keyfile_intern_new, |