mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-14 12:05:03 +00:00
logging: add special logging level "KEEP"
Without this, the user cannot configure only certain logging domains without touching them all. E.g. # nmcli general logging level DEBUG domains PLATFORM will disable all non-PLATFORM domains. Well, the user can do: # nmcli general logging level INFO domains PLATFORM:DEBUG # nmcli general logging level DEBUG domains ALL:INFO,PLATFORM but in this case all non-PLATFORM domains are reset explicitly. Now the user can: # nmcli general logging level KEEP domains PLATFORM:DEBUG # nmcli general logging level DEBUG domains ALL:KEEP,PLATFORM which will only change the platform domain.
This commit is contained in:
parent
cc6b07c439
commit
fd87ce503c
|
@ -184,7 +184,13 @@
|
||||||
</tp:docstring>
|
</tp:docstring>
|
||||||
<arg name="level" type="s" direction="in">
|
<arg name="level" type="s" direction="in">
|
||||||
<tp:docstring>
|
<tp:docstring>
|
||||||
One of [ERR, WARN, INFO, DEBUG, TRACE].
|
One of [ERR, WARN, INFO, DEBUG, TRACE, OFF, KEEP].
|
||||||
|
This level is applied to the domains as specified in the domains
|
||||||
|
argument. Except for the special level "KEEP", all unmentioned
|
||||||
|
domains are disabled entirely. "KEEP" is special and allows
|
||||||
|
not to change the current setting except for the specified
|
||||||
|
domains. E.g. level=KEEP and domains=PLATFORM:DEBUG will only
|
||||||
|
touch the platform domain.
|
||||||
</tp:docstring>
|
</tp:docstring>
|
||||||
</arg>
|
</arg>
|
||||||
<arg name="domains" type="s" direction="in">
|
<arg name="domains" type="s" direction="in">
|
||||||
|
|
|
@ -79,6 +79,7 @@ static const LogLevelDesc level_desc[_LOGL_N] = {
|
||||||
[LOGL_WARN] = { "WARN", "<warn>", LOG_WARNING, G_LOG_LEVEL_WARNING, FALSE },
|
[LOGL_WARN] = { "WARN", "<warn>", LOG_WARNING, G_LOG_LEVEL_WARNING, FALSE },
|
||||||
[LOGL_ERR] = { "ERR", "<error>", LOG_ERR, G_LOG_LEVEL_WARNING, TRUE },
|
[LOGL_ERR] = { "ERR", "<error>", LOG_ERR, G_LOG_LEVEL_WARNING, TRUE },
|
||||||
[_LOGL_OFF] = { "OFF", NULL, 0, 0, FALSE },
|
[_LOGL_OFF] = { "OFF", NULL, 0, 0, FALSE },
|
||||||
|
[_LOGL_KEEP] = { "KEEP", NULL, 0, 0, FALSE },
|
||||||
};
|
};
|
||||||
|
|
||||||
static const LogDesc domain_descs[] = {
|
static const LogDesc domain_descs[] = {
|
||||||
|
@ -181,6 +182,11 @@ nm_logging_setup (const char *level,
|
||||||
if (level && *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;
|
||||||
|
if (new_log_level == _LOGL_KEEP) {
|
||||||
|
new_log_level = log_level;
|
||||||
|
for (i = 0; i < G_N_ELEMENTS (new_logging); i++)
|
||||||
|
new_logging[i] = logging[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* domains */
|
/* domains */
|
||||||
|
@ -249,6 +255,10 @@ nm_logging_setup (const char *level,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (domain_log_level == _LOGL_KEEP) {
|
||||||
|
for (i = 0; i < G_N_ELEMENTS (new_logging); i++)
|
||||||
|
new_logging[i] = (new_logging[i] & ~bits) | (logging[i] & bits);
|
||||||
|
} else {
|
||||||
for (i = 0; i < G_N_ELEMENTS (new_logging); i++) {
|
for (i = 0; i < G_N_ELEMENTS (new_logging); i++) {
|
||||||
if (i < domain_log_level)
|
if (i < domain_log_level)
|
||||||
new_logging[i] &= ~bits;
|
new_logging[i] &= ~bits;
|
||||||
|
@ -256,6 +266,7 @@ nm_logging_setup (const char *level,
|
||||||
new_logging[i] |= bits;
|
new_logging[i] |= bits;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
g_strfreev (tmp);
|
g_strfreev (tmp);
|
||||||
|
|
||||||
if (log_domains != (char *)domains) {
|
if (log_domains != (char *)domains) {
|
||||||
|
|
|
@ -94,6 +94,7 @@ typedef enum { /*< skip >*/
|
||||||
_LOGL_N_REAL, /* the number of actual logging levels */
|
_LOGL_N_REAL, /* the number of actual logging levels */
|
||||||
|
|
||||||
_LOGL_OFF = _LOGL_N_REAL, /* special logging level that is always disabled. */
|
_LOGL_OFF = _LOGL_N_REAL, /* special logging level that is always disabled. */
|
||||||
|
_LOGL_KEEP, /* special logging level to indicate that the logging level should not be changed. */
|
||||||
|
|
||||||
_LOGL_N, /* the number of logging levels including "OFF" */
|
_LOGL_N, /* the number of logging levels including "OFF" */
|
||||||
} NMLogLevel;
|
} NMLogLevel;
|
||||||
|
|
Loading…
Reference in a new issue