logging: correctly print new logging level and domains on changes

Previously the input would simply be printed, but if you're not
changing either the level or domains (ie sending "") then the
unchanged logging domains wouldn't be printed, only "".
This commit is contained in:
Dan Williams
2010-05-04 12:06:00 -07:00
parent e99ad94411
commit defaee09e5
3 changed files with 39 additions and 1 deletions

View File

@@ -179,6 +179,36 @@ nm_logging_setup (const char *level, const char *domains, GError **error)
return TRUE;
}
const char *
nm_logging_level_to_string (void)
{
const LogDesc *diter;
for (diter = &level_descs[0]; diter->name; diter++) {
if (diter->num == log_level)
return diter->name;
}
g_warn_if_reached ();
return "";
}
char *
nm_logging_domains_to_string (void)
{
const LogDesc *diter;
GString *str;
str = g_string_sized_new (75);
for (diter = &domain_descs[0]; diter->name; diter++) {
if (diter->num & log_domains) {
if (str->len)
g_string_append_c (str, ',');
g_string_append (str, diter->name);
}
}
return g_string_free (str, FALSE);
}
void _nm_log (const char *loc,
const char *func,
guint32 domain,

View File

@@ -88,6 +88,9 @@ void _nm_log (const char *loc, const char *func,
guint32 domain, guint32 level,
const char *fmt, ...);
const char *nm_logging_level_to_string (void);
char *nm_logging_domains_to_string (void);
/* Undefine the nm-utils.h logging stuff to ensure errors */
#undef nm_print_backtrace
#undef nm_get_timestamp