summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-08-01 14:12:34 +0200
committerThomas Haller <thaller@redhat.com>2015-08-04 11:21:57 +0200
commit8c3f1812ead7fc5078cc1742643906fbf965bccd (patch)
treed9ce0c72de8815904ed704837ac4795f2278ddcf
parent655b85bfea2c8e4594c6da304c844da64c0faa4d (diff)
downloadNetworkManager-8c3f1812ead7fc5078cc1742643906fbf965bccd.tar.gz
logging: support an "OFF" logging level
The only way to disable logging for a domain entirely is to omit the domain from the "domains" list. For example: "level=INFO, domains=PLATFORM,..." Now add an explicit level "OFF" to facilitate configuration like: "level=INFO, domains=ALL,WIFI_SCAN:OFF" It also supports "level=OFF, domains=PLATFORM:INFO" but this is for the most part equivalent to "level=INFO, domains=PLATFORM"
-rw-r--r--clients/cli/nmcli-completion2
-rw-r--r--man/NetworkManager.conf.xml.in4
-rw-r--r--src/nm-logging.c13
-rw-r--r--src/nm-logging.h6
4 files changed, 16 insertions, 9 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 a98972caa4..2398e8ae73 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_N];
+static NMLogDomain logging[_LOGL_N_REAL];
static gboolean logging_set_up;
enum {
LOG_BACKEND_GLIB,
@@ -82,6 +82,7 @@ static const LogLevelDesc level_desc[_LOGL_N] = {
[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[] = {
@@ -253,10 +254,12 @@ nm_logging_setup (const char *level,
continue;
}
- for (i = 0; i < domain_log_level; i++)
- new_logging[i] &= ~bits;
- for (i = domain_log_level; i < _LOGL_N; i++)
- new_logging[i] |= bits;
+ for (i = 0; i < G_N_ELEMENTS (new_logging); i++) {
+ if (i < domain_log_level)
+ new_logging[i] &= ~bits;
+ else
+ new_logging[i] |= bits;
+ }
}
g_strfreev (tmp);
diff --git a/src/nm-logging.h b/src/nm-logging.h
index 9fbe62721d..a346a7a657 100644
--- a/src/nm-logging.h
+++ b/src/nm-logging.h
@@ -90,7 +90,11 @@ typedef enum { /*< skip >*/
LOGL_WARN,
LOGL_ERR,
- _LOGL_N, /* the number of logging levels */
+ _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__)