diff --git a/src/config/nm-config.c b/src/config/nm-config.c index 810878691..7f1238c18 100644 --- a/src/config/nm-config.c +++ b/src/config/nm-config.c @@ -24,6 +24,7 @@ #include #include "nm-config.h" +#include "nm-logging.h" #include @@ -138,25 +139,35 @@ static char *cli_connectivity_response; static GOptionEntry config_options[] = { { "config", 0, 0, G_OPTION_ARG_FILENAME, &cli_config_path, N_("Config file location"), N_("/path/to/config.file") }, { "plugins", 0, 0, G_OPTION_ARG_STRING, &cli_plugins, N_("List of plugins separated by ','"), N_("plugin1,plugin2") }, - /* Translators: Do not translate the values in the square brackets */ - { "log-level", 0, 0, G_OPTION_ARG_STRING, &cli_log_level, N_("Log level: one of [ERR, WARN, INFO, DEBUG]"), "INFO" }, + { "log-level", 0, 0, G_OPTION_ARG_STRING, &cli_log_level, N_("Log level: one of [%s]"), "INFO" }, { "log-domains", 0, 0, G_OPTION_ARG_STRING, &cli_log_domains, - /* Translators: Do not translate the values in the square brackets */ - N_("Log domains separated by ',': any combination of\n" - " [NONE,HW,RFKILL,ETHER,WIFI,BT,MB,DHCP4,DHCP6,PPP,\n" - " WIFI_SCAN,IP4,IP6,AUTOIP4,DNS,VPN,SHARING,SUPPLICANT,\n" - " AGENTS,SETTINGS,SUSPEND,CORE,DEVICE,OLPC,WIMAX,\n" - " INFINIBAND,FIREWALL,ADSL]"), - "HW,RFKILL,WIFI" }, + N_("Log domains separated by ',': any combination of [%s]"), + "PLATFORM,RFKILL,WIFI" }, { "connectivity-uri", 0, 0, G_OPTION_ARG_STRING, &cli_connectivity_uri, N_("An http(s) address for checking internet connectivity"), "http://example.com" }, { "connectivity-interval", 0, 0, G_OPTION_ARG_INT, &cli_connectivity_interval, N_("The interval between connectivity checks (in seconds)"), "60" }, { "connectivity-response", 0, 0, G_OPTION_ARG_STRING, &cli_connectivity_response, N_("The expected start of the response"), N_("Bingo!") }, {NULL} }; +static gboolean config_options_inited; GOptionEntry * nm_config_get_options (void) { + if (!config_options_inited) { + int i; + + for (i = 0; config_options[i].long_name; i++) { + if (!strcmp (config_options[i].long_name, "log-level")) { + config_options[i].description = g_strdup_printf (config_options[i].description, + nm_logging_all_levels_to_string ()); + } else if (!strcmp (config_options[i].long_name, "log-domains")) { + config_options[i].description = g_strdup_printf (config_options[i].description, + nm_logging_all_domains_to_string ()); + } + } + config_options_inited = TRUE; + } + return config_options; } diff --git a/src/logging/nm-logging.c b/src/logging/nm-logging.c index 8c6638280..e087fa9de 100644 --- a/src/logging/nm-logging.c +++ b/src/logging/nm-logging.c @@ -209,6 +209,25 @@ nm_logging_level_to_string (void) return ""; } +const char * +nm_logging_all_levels_to_string (void) +{ + static GString *str; + + if (G_UNLIKELY (!str)) { + const LogDesc *diter; + + str = g_string_new (NULL); + for (diter = &level_descs[0]; diter->name; diter++) { + if (str->len) + g_string_append_c (str, ','); + g_string_append (str, diter->name); + } + } + + return str->str; +} + char * nm_logging_domains_to_string (void) { @@ -226,6 +245,29 @@ nm_logging_domains_to_string (void) return g_string_free (str, FALSE); } +const char * +nm_logging_all_domains_to_string (void) +{ + static GString *str; + + if (G_UNLIKELY (!str)) { + const LogDesc *diter; + + str = g_string_new ("DEFAULT"); + for (diter = &domain_descs[0]; diter->name; diter++) { + g_string_append_c (str, ','); + g_string_append (str, diter->name); + if (diter->num == LOGD_DHCP6) + g_string_append (str, ",DHCP"); + else if (diter->num == LOGD_IP6) + g_string_append (str, ",IP"); + } + g_string_append (str, ",ALL"); + } + + return str->str; +} + gboolean nm_logging_level_enabled (guint32 level) { diff --git a/src/logging/nm-logging.h b/src/logging/nm-logging.h index 2c6dadb98..00a92f5aa 100644 --- a/src/logging/nm-logging.h +++ b/src/logging/nm-logging.h @@ -108,6 +108,9 @@ char *nm_logging_domains_to_string (void); gboolean nm_logging_level_enabled (guint32 level); gboolean nm_logging_domain_enabled (guint32 domain); +const char *nm_logging_all_levels_to_string (void); +const char *nm_logging_all_domains_to_string (void); + /* Undefine the nm-utils.h logging stuff to ensure errors */ #undef nm_get_timestamp #undef nm_info