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