logging: fix "nmcli gen log level FOO"

The change to per-domain log levels means that when setting just the
level, we need to re-set the log level for each domain (since it's the
"logging" bit array that actually determines what gets logged).
nm_logging_setup() was dealing correctly with domains=NULL, but not
domains="" (which is what happens when it is invoked with only a level
via D-Bus), so doing "nmcli gen log level DEBUG" would change the
"default" log level, but leave all of the domains still at their
previous level:

danw@laptop:NetworkManager> nmcli g log
LEVEL  DOMAINS
INFO   PLATFORM,RFKILL,ETHER,WIFI,BT,MB,DHCP4,DHCP6,PPP,IP4,IP6...

danw@laptop:NetworkManager> nmcli g log level DEBUG
danw@laptop:NetworkManager> nmcli g log
LEVEL  DOMAINS
DEBUG  PLATFORM:INFO,RFKILL:INFO,ETHER:INFO,WIFI:INFO,BT:INFO...
This commit is contained in:
Dan Winship
2014-01-21 09:54:50 -05:00
parent 2b87dbb2a9
commit 1d42962e7f

View File

@@ -159,23 +159,21 @@ nm_logging_setup (const char *level,
GString *unrecognized = NULL;
guint64 new_logging[LOGL_MAX];
guint32 new_log_level = log_level;
char **tmp, **iter;
int i;
if (!domains)
domains = log_domains ? log_domains : "DEFAULT";
for (i = 0; i < LOGL_MAX; i++)
new_logging[i] = 0;
/* levels */
if (level && strlen (level)) {
if (level && *level) {
if (!match_log_level (level, &new_log_level, error))
return FALSE;
}
/* domains */
if (domains && strlen (domains)) {
char **tmp, **iter;
if (!domains || !*domains)
domains = log_domains ? log_domains : "DEFAULT";
tmp = g_strsplit_set (domains, ", ", 0);
for (iter = tmp; iter && *iter; iter++) {
@@ -249,11 +247,9 @@ nm_logging_setup (const char *level,
log_domains = g_strdup (domains);
}
log_level = new_log_level;
for (i = 0; i < LOGL_MAX; i++)
logging[i] = new_logging[i];
}
log_level = new_log_level;
if (unrecognized)
*bad_domains = g_string_free (unrecognized, FALSE);