summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-05-23 10:56:27 +0200
committerThomas Haller <thaller@redhat.com>2016-05-24 19:39:25 +0200
commit13101f8444863c0ae3639658c9c3f35e9487d8dd (patch)
treec8a43749fc6d343ae093d38352fb3db110015482
parent4c7fbcc941d5aba8b1d7858080fe7818c064104c (diff)
downloadNetworkManager-13101f8444863c0ae3639658c9c3f35e9487d8dd.tar.gz
logging: add nm_logging_get_level() function
-rw-r--r--src/nm-logging.c21
-rw-r--r--src/nm-logging.h2
2 files changed, 23 insertions, 0 deletions
diff --git a/src/nm-logging.c b/src/nm-logging.c
index a2581add24..e517d8d4c6 100644
--- a/src/nm-logging.c
+++ b/src/nm-logging.c
@@ -445,6 +445,27 @@ nm_logging_all_domains_to_string (void)
return str->str;
}
+/**
+ * nm_logging_get_level:
+ * @domain: find the lowest enabled logging level for the
+ * given domain. If this is a set of multiple
+ * domains, the most verbose level will be returned.
+ *
+ * Returns: the lowest (most verbose) logging level for the
+ * give @domain, or %_LOGL_OFF if it is disabled.
+ **/
+NMLogLevel
+nm_logging_get_level (NMLogDomain domain)
+{
+ NMLogLevel sl = _LOGL_OFF;
+
+ G_STATIC_ASSERT (LOGL_TRACE == 0);
+ while ( sl > LOGL_TRACE
+ && nm_logging_enabled (sl - 1, domain))
+ sl--;
+ return sl;
+}
+
#if SYSTEMD_JOURNAL
__attribute__((__format__ (__printf__, 4, 5)))
static void
diff --git a/src/nm-logging.h b/src/nm-logging.h
index 1cb5a5a5d9..329b457caf 100644
--- a/src/nm-logging.h
+++ b/src/nm-logging.h
@@ -168,6 +168,8 @@ nm_logging_enabled (NMLogLevel level, NMLogDomain domain)
&& !!(_nm_logging_enabled_state[level] & domain);
}
+NMLogLevel nm_logging_get_level (NMLogDomain domain);
+
const char *nm_logging_all_levels_to_string (void);
const char *nm_logging_all_domains_to_string (void);