logging: add nm_logging_get_level() function

This commit is contained in:
Thomas Haller 2016-05-23 10:56:27 +02:00
parent 4c7fbcc941
commit 13101f8444
2 changed files with 23 additions and 0 deletions

View file

@ -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

View file

@ -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);