summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-08-04 11:25:21 +0200
committerThomas Haller <thaller@redhat.com>2015-08-04 11:25:21 +0200
commit63d27397dba531d86cd4daa7bc33c8314e16f0b1 (patch)
treefb390563f1c8d2a603eddece2cb551b686532043
parent7c38b784632ecc490f7440a286dc81b452dc6213 (diff)
parent8a4ad96ec158eba038801a2bd8267d2bcf188dac (diff)
downloadNetworkManager-63d27397dba531d86cd4daa7bc33c8314e16f0b1.tar.gz
logging: merge branch 'th/logging-off-bgo753128'
https://bugzilla.gnome.org/show_bug.cgi?id=753128
-rw-r--r--clients/cli/nmcli-completion2
-rw-r--r--man/NetworkManager.conf.xml.in4
-rw-r--r--src/nm-logging.c57
-rw-r--r--src/nm-logging.h6
4 files changed, 38 insertions, 31 deletions
diff --git a/clients/cli/nmcli-completion b/clients/cli/nmcli-completion
index eb352d5269..4a55f3dbc6 100644
--- a/clients/cli/nmcli-completion
+++ b/clients/cli/nmcli-completion
@@ -306,7 +306,7 @@ _nmcli_compl_ARGS()
case "${words[0]}" in
level)
if [[ "${#words[@]}" -eq 2 ]]; then
- _nmcli_list "ERR WARN INFO DEBUG TRACE"
+ _nmcli_list "OFF ERR WARN INFO DEBUG TRACE"
return 0
fi
;;
diff --git a/man/NetworkManager.conf.xml.in b/man/NetworkManager.conf.xml.in
index 850e772fc1..30faab4d54 100644
--- a/man/NetworkManager.conf.xml.in
+++ b/man/NetworkManager.conf.xml.in
@@ -396,7 +396,7 @@ unmanaged-devices=mac:00:22:68:1c:59:b1;mac:00:1E:65:30:D1:C4;interface-name:eth
<varlistentry>
<term><varname>level</varname></term>
<listitem><para>The default logging verbosity level.
- One of <literal>ERR</literal>,
+ One of <literal>OFF</literal>, <literal>ERR</literal>,
<literal>WARN</literal>, <literal>INFO</literal>,
<literal>DEBUG</literal>, <literal>TRACE</literal>. The ERR
level logs only critical errors. WARN logs warnings that may
@@ -419,7 +419,7 @@ unmanaged-devices=mac:00:22:68:1c:59:b1;mac:00:1E:65:30:D1:C4;interface-name:eth
ALL, DEFAULT, DHCP, IP.</para>
<para>You can specify per-domain log level overrides by
adding a colon and a log level to any domain. E.g.,
- "<literal>WIFI:DEBUG</literal>".</para></listitem>
+ "<literal>WIFI:DEBUG,WIFI_SCAN:OFF</literal>".</para></listitem>
</varlistentry>
<varlistentry>
<para>Domain descriptions:
diff --git a/src/nm-logging.c b/src/nm-logging.c
index d7b85c1d4a..6ee09fbf3d 100644
--- a/src/nm-logging.c
+++ b/src/nm-logging.c
@@ -53,7 +53,7 @@ nm_log_handler (const gchar *log_domain,
static NMLogLevel log_level = LOGL_INFO;
static char *log_domains;
-static NMLogDomain logging[LOGL_MAX];
+static NMLogDomain logging[_LOGL_N_REAL];
static gboolean logging_set_up;
enum {
LOG_BACKEND_GLIB,
@@ -76,16 +76,16 @@ typedef struct {
gboolean full_details;
} LogLevelDesc;
-static const LogLevelDesc level_desc[LOGL_MAX] = {
+static const LogLevelDesc level_desc[_LOGL_N] = {
[LOGL_TRACE] = { "TRACE", "<trace>", LOG_DEBUG, G_LOG_LEVEL_DEBUG, TRUE },
[LOGL_DEBUG] = { "DEBUG", "<debug>", LOG_INFO, G_LOG_LEVEL_DEBUG, TRUE },
[LOGL_INFO] = { "INFO", "<info>", LOG_INFO, G_LOG_LEVEL_MESSAGE, FALSE },
[LOGL_WARN] = { "WARN", "<warn>", LOG_WARNING, G_LOG_LEVEL_WARNING, FALSE },
[LOGL_ERR] = { "ERR", "<error>", LOG_ERR, G_LOG_LEVEL_WARNING, TRUE },
+ [_LOGL_OFF] = { "OFF", NULL, 0, 0, FALSE },
};
static const LogDesc domain_descs[] = {
- { LOGD_NONE, "NONE" },
{ LOGD_PLATFORM, "PLATFORM" },
{ LOGD_RFKILL, "RFKILL" },
{ LOGD_ETHER, "ETHER" },
@@ -149,7 +149,7 @@ match_log_level (const char *level,
{
int i;
- for (i = 0; i < LOGL_MAX; i++) {
+ for (i = 0; i < G_N_ELEMENTS (level_desc); i++) {
if (!g_ascii_strcasecmp (level_desc[i].name, level)) {
*out_level = i;
return TRUE;
@@ -168,7 +168,7 @@ nm_logging_setup (const char *level,
GError **error)
{
GString *unrecognized = NULL;
- NMLogDomain new_logging[LOGL_MAX];
+ NMLogDomain new_logging[G_N_ELEMENTS (logging)];
NMLogLevel new_log_level = log_level;
char **tmp, **iter;
int i;
@@ -178,7 +178,7 @@ nm_logging_setup (const char *level,
logging_set_up = TRUE;
- for (i = 0; i < LOGL_MAX; i++)
+ for (i = 0; i < G_N_ELEMENTS (new_logging); i++)
new_logging[i] = 0;
/* levels */
@@ -236,27 +236,29 @@ nm_logging_setup (const char *level,
break;
}
}
- }
- if (!bits) {
- if (!bad_domains) {
- g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_LOG_DOMAIN,
- _("Unknown log domain '%s'"), *iter);
- return FALSE;
+ if (!bits) {
+ if (!bad_domains) {
+ g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_LOG_DOMAIN,
+ _("Unknown log domain '%s'"), *iter);
+ return FALSE;
+ }
+
+ if (unrecognized)
+ g_string_append (unrecognized, ", ");
+ else
+ unrecognized = g_string_new (NULL);
+ g_string_append (unrecognized, *iter);
+ continue;
}
+ }
- if (unrecognized)
- g_string_append (unrecognized, ", ");
+ for (i = 0; i < G_N_ELEMENTS (new_logging); i++) {
+ if (i < domain_log_level)
+ new_logging[i] &= ~bits;
else
- unrecognized = g_string_new (NULL);
- g_string_append (unrecognized, *iter);
- continue;
+ new_logging[i] |= bits;
}
-
- for (i = 0; i < domain_log_level; i++)
- new_logging[i] &= ~bits;
- for (i = domain_log_level; i < LOGL_MAX; i++)
- new_logging[i] |= bits;
}
g_strfreev (tmp);
@@ -268,7 +270,7 @@ nm_logging_setup (const char *level,
g_clear_pointer (&logging_domains_to_string, g_free);
log_level = new_log_level;
- for (i = 0; i < LOGL_MAX; i++)
+ for (i = 0; i < G_N_ELEMENTS (new_logging); i++)
logging[i] = new_logging[i];
if (unrecognized)
@@ -292,7 +294,7 @@ nm_logging_all_levels_to_string (void)
int i;
str = g_string_new (NULL);
- for (i = 0; i < LOGL_MAX; i++) {
+ for (i = 0; i < G_N_ELEMENTS (level_desc); i++) {
if (str->len)
g_string_append_c (str, ',');
g_string_append (str, level_desc[i].name);
@@ -335,7 +337,7 @@ nm_logging_domains_to_string (void)
}
/* Check if it's logging at a higher level than the default. */
if (!(diter->num & logging[log_level])) {
- for (i = log_level + 1; i < LOGL_MAX; i++) {
+ for (i = log_level + 1; i < G_N_ELEMENTS (logging); i++) {
if (diter->num & logging[i]) {
g_string_append_printf (str, ":%s", level_desc[i].name);
break;
@@ -374,7 +376,8 @@ nm_logging_all_domains_to_string (void)
gboolean
nm_logging_enabled (NMLogLevel level, NMLogDomain domain)
{
- g_return_val_if_fail (level < LOGL_MAX, FALSE);
+ if ((guint) level >= G_N_ELEMENTS (logging))
+ g_return_val_if_reached (FALSE);
_ensure_initialized ();
@@ -423,7 +426,7 @@ _nm_log_impl (const char *file,
char *fullmsg = NULL;
GTimeVal tv;
- if ((guint) level >= LOGL_MAX)
+ if ((guint) level >= G_N_ELEMENTS (logging))
g_return_if_reached ();
_ensure_initialized ();
diff --git a/src/nm-logging.h b/src/nm-logging.h
index 6af672844d..a346a7a657 100644
--- a/src/nm-logging.h
+++ b/src/nm-logging.h
@@ -90,7 +90,11 @@ typedef enum { /*< skip >*/
LOGL_WARN,
LOGL_ERR,
- LOGL_MAX
+ _LOGL_N_REAL, /* the number of actual logging levels */
+
+ _LOGL_OFF = _LOGL_N_REAL, /* special logging level that is always disabled. */
+
+ _LOGL_N, /* the number of logging levels including "OFF" */
} NMLogLevel;
#define nm_log_err(domain, ...) nm_log (LOGL_ERR, (domain), __VA_ARGS__)