mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 01:20:07 +01:00
logging: merge branch 'th/logging-off-bgo753128'
https://bugzilla.gnome.org/show_bug.cgi?id=753128
This commit is contained in:
commit
63d27397db
4 changed files with 39 additions and 32 deletions
|
|
@ -306,7 +306,7 @@ _nmcli_compl_ARGS()
|
|||
case "${words[0]}" in
|
||||
level)
|
||||
if [[ "${#words[@]}" -eq 2 ]]; then
|
||||
_nmcli_list "ERR WARN INFO DEBUG TRACE"
|
||||
_nmcli_list "OFF ERR WARN INFO DEBUG TRACE"
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
|
|
|
|||
|
|
@ -396,7 +396,7 @@ unmanaged-devices=mac:00:22:68:1c:59:b1;mac:00:1E:65:30:D1:C4;interface-name:eth
|
|||
<varlistentry>
|
||||
<term><varname>level</varname></term>
|
||||
<listitem><para>The default logging verbosity level.
|
||||
One of <literal>ERR</literal>,
|
||||
One of <literal>OFF</literal>, <literal>ERR</literal>,
|
||||
<literal>WARN</literal>, <literal>INFO</literal>,
|
||||
<literal>DEBUG</literal>, <literal>TRACE</literal>. The ERR
|
||||
level logs only critical errors. WARN logs warnings that may
|
||||
|
|
@ -419,7 +419,7 @@ unmanaged-devices=mac:00:22:68:1c:59:b1;mac:00:1E:65:30:D1:C4;interface-name:eth
|
|||
ALL, DEFAULT, DHCP, IP.</para>
|
||||
<para>You can specify per-domain log level overrides by
|
||||
adding a colon and a log level to any domain. E.g.,
|
||||
"<literal>WIFI:DEBUG</literal>".</para></listitem>
|
||||
"<literal>WIFI:DEBUG,WIFI_SCAN:OFF</literal>".</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<para>Domain descriptions:
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ nm_log_handler (const gchar *log_domain,
|
|||
|
||||
static NMLogLevel log_level = LOGL_INFO;
|
||||
static char *log_domains;
|
||||
static NMLogDomain logging[LOGL_MAX];
|
||||
static NMLogDomain logging[_LOGL_N_REAL];
|
||||
static gboolean logging_set_up;
|
||||
enum {
|
||||
LOG_BACKEND_GLIB,
|
||||
|
|
@ -76,16 +76,16 @@ typedef struct {
|
|||
gboolean full_details;
|
||||
} LogLevelDesc;
|
||||
|
||||
static const LogLevelDesc level_desc[LOGL_MAX] = {
|
||||
static const LogLevelDesc level_desc[_LOGL_N] = {
|
||||
[LOGL_TRACE] = { "TRACE", "<trace>", LOG_DEBUG, G_LOG_LEVEL_DEBUG, TRUE },
|
||||
[LOGL_DEBUG] = { "DEBUG", "<debug>", LOG_INFO, G_LOG_LEVEL_DEBUG, TRUE },
|
||||
[LOGL_INFO] = { "INFO", "<info>", LOG_INFO, G_LOG_LEVEL_MESSAGE, FALSE },
|
||||
[LOGL_WARN] = { "WARN", "<warn>", LOG_WARNING, G_LOG_LEVEL_WARNING, FALSE },
|
||||
[LOGL_ERR] = { "ERR", "<error>", LOG_ERR, G_LOG_LEVEL_WARNING, TRUE },
|
||||
[_LOGL_OFF] = { "OFF", NULL, 0, 0, FALSE },
|
||||
};
|
||||
|
||||
static const LogDesc domain_descs[] = {
|
||||
{ LOGD_NONE, "NONE" },
|
||||
{ LOGD_PLATFORM, "PLATFORM" },
|
||||
{ LOGD_RFKILL, "RFKILL" },
|
||||
{ LOGD_ETHER, "ETHER" },
|
||||
|
|
@ -149,7 +149,7 @@ match_log_level (const char *level,
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < LOGL_MAX; i++) {
|
||||
for (i = 0; i < G_N_ELEMENTS (level_desc); i++) {
|
||||
if (!g_ascii_strcasecmp (level_desc[i].name, level)) {
|
||||
*out_level = i;
|
||||
return TRUE;
|
||||
|
|
@ -168,7 +168,7 @@ nm_logging_setup (const char *level,
|
|||
GError **error)
|
||||
{
|
||||
GString *unrecognized = NULL;
|
||||
NMLogDomain new_logging[LOGL_MAX];
|
||||
NMLogDomain new_logging[G_N_ELEMENTS (logging)];
|
||||
NMLogLevel new_log_level = log_level;
|
||||
char **tmp, **iter;
|
||||
int i;
|
||||
|
|
@ -178,7 +178,7 @@ nm_logging_setup (const char *level,
|
|||
|
||||
logging_set_up = TRUE;
|
||||
|
||||
for (i = 0; i < LOGL_MAX; i++)
|
||||
for (i = 0; i < G_N_ELEMENTS (new_logging); i++)
|
||||
new_logging[i] = 0;
|
||||
|
||||
/* levels */
|
||||
|
|
@ -236,27 +236,29 @@ nm_logging_setup (const char *level,
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!bits) {
|
||||
if (!bad_domains) {
|
||||
g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_LOG_DOMAIN,
|
||||
_("Unknown log domain '%s'"), *iter);
|
||||
return FALSE;
|
||||
if (!bits) {
|
||||
if (!bad_domains) {
|
||||
g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_LOG_DOMAIN,
|
||||
_("Unknown log domain '%s'"), *iter);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (unrecognized)
|
||||
g_string_append (unrecognized, ", ");
|
||||
else
|
||||
unrecognized = g_string_new (NULL);
|
||||
g_string_append (unrecognized, *iter);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (unrecognized)
|
||||
g_string_append (unrecognized, ", ");
|
||||
else
|
||||
unrecognized = g_string_new (NULL);
|
||||
g_string_append (unrecognized, *iter);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (i = 0; i < domain_log_level; i++)
|
||||
new_logging[i] &= ~bits;
|
||||
for (i = domain_log_level; i < LOGL_MAX; i++)
|
||||
new_logging[i] |= bits;
|
||||
for (i = 0; i < G_N_ELEMENTS (new_logging); i++) {
|
||||
if (i < domain_log_level)
|
||||
new_logging[i] &= ~bits;
|
||||
else
|
||||
new_logging[i] |= bits;
|
||||
}
|
||||
}
|
||||
g_strfreev (tmp);
|
||||
|
||||
|
|
@ -268,7 +270,7 @@ nm_logging_setup (const char *level,
|
|||
g_clear_pointer (&logging_domains_to_string, g_free);
|
||||
|
||||
log_level = new_log_level;
|
||||
for (i = 0; i < LOGL_MAX; i++)
|
||||
for (i = 0; i < G_N_ELEMENTS (new_logging); i++)
|
||||
logging[i] = new_logging[i];
|
||||
|
||||
if (unrecognized)
|
||||
|
|
@ -292,7 +294,7 @@ nm_logging_all_levels_to_string (void)
|
|||
int i;
|
||||
|
||||
str = g_string_new (NULL);
|
||||
for (i = 0; i < LOGL_MAX; i++) {
|
||||
for (i = 0; i < G_N_ELEMENTS (level_desc); i++) {
|
||||
if (str->len)
|
||||
g_string_append_c (str, ',');
|
||||
g_string_append (str, level_desc[i].name);
|
||||
|
|
@ -335,7 +337,7 @@ nm_logging_domains_to_string (void)
|
|||
}
|
||||
/* Check if it's logging at a higher level than the default. */
|
||||
if (!(diter->num & logging[log_level])) {
|
||||
for (i = log_level + 1; i < LOGL_MAX; i++) {
|
||||
for (i = log_level + 1; i < G_N_ELEMENTS (logging); i++) {
|
||||
if (diter->num & logging[i]) {
|
||||
g_string_append_printf (str, ":%s", level_desc[i].name);
|
||||
break;
|
||||
|
|
@ -374,7 +376,8 @@ nm_logging_all_domains_to_string (void)
|
|||
gboolean
|
||||
nm_logging_enabled (NMLogLevel level, NMLogDomain domain)
|
||||
{
|
||||
g_return_val_if_fail (level < LOGL_MAX, FALSE);
|
||||
if ((guint) level >= G_N_ELEMENTS (logging))
|
||||
g_return_val_if_reached (FALSE);
|
||||
|
||||
_ensure_initialized ();
|
||||
|
||||
|
|
@ -423,7 +426,7 @@ _nm_log_impl (const char *file,
|
|||
char *fullmsg = NULL;
|
||||
GTimeVal tv;
|
||||
|
||||
if ((guint) level >= LOGL_MAX)
|
||||
if ((guint) level >= G_N_ELEMENTS (logging))
|
||||
g_return_if_reached ();
|
||||
|
||||
_ensure_initialized ();
|
||||
|
|
|
|||
|
|
@ -90,7 +90,11 @@ typedef enum { /*< skip >*/
|
|||
LOGL_WARN,
|
||||
LOGL_ERR,
|
||||
|
||||
LOGL_MAX
|
||||
_LOGL_N_REAL, /* the number of actual logging levels */
|
||||
|
||||
_LOGL_OFF = _LOGL_N_REAL, /* special logging level that is always disabled. */
|
||||
|
||||
_LOGL_N, /* the number of logging levels including "OFF" */
|
||||
} NMLogLevel;
|
||||
|
||||
#define nm_log_err(domain, ...) nm_log (LOGL_ERR, (domain), __VA_ARGS__)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue