summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nm-logging.c13
-rw-r--r--src/nm-logging.h6
2 files changed, 13 insertions, 6 deletions
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__)