Commit 5ec2138a authored by Peter Hutterer's avatar Peter Hutterer Committed by George Kiagiadakis
Browse files

log: support strings as level selectors in WIREPLUMBER_DEBUG

This allows for WIREPLUMBER_DEBUG="D" which avoids users having to
remember which numerical value the various levels have. The strings to
select are the ones printed by the logger, i.e. UECWMIDT.
parent 21266a5b
Pipeline #448959 passed with stages
in 2 minutes and 6 seconds
...@@ -10,7 +10,8 @@ Getting debug messages on the command line is a matter of setting the ...@@ -10,7 +10,8 @@ Getting debug messages on the command line is a matter of setting the
WIREPLUMBER_DEBUG=level:category1,category2,... WIREPLUMBER_DEBUG=level:category1,category2,...
``level`` can be a number from 1 to 5 and defines the minimum debug level to show: ``level`` can be one of ``CEWMIDT`` or a numerical log level as listed below.
In either case it defines the minimum debug level to show:
0. critical warnings and fatal errors (``C`` & ``E`` in the log) 0. critical warnings and fatal errors (``C`` & ``E`` in the log)
1. warnings (``W``) 1. warnings (``W``)
...@@ -50,13 +51,13 @@ Show all messages: ...@@ -50,13 +51,13 @@ Show all messages:
.. code:: .. code::
WIREPLUMBER_DEBUG=5 WIREPLUMBER_DEBUG=D
Show all messages up to the *debug* level (E, C, W, M, I & D), excluding *trace*: Show all messages up to the *debug* level (E, C, W, M, I & D), excluding *trace*:
.. code:: .. code::
WIREPLUMBER_DEBUG=4 WIREPLUMBER_DEBUG=M
Show all messages up to the *message* level (E, C, W & M), Show all messages up to the *message* level (E, C, W & M),
excluding *info*, *debug* & *trace* excluding *info*, *debug* & *trace*
...@@ -70,13 +71,13 @@ Show all messages from the wireplumber library: ...@@ -70,13 +71,13 @@ Show all messages from the wireplumber library:
.. code:: .. code::
WIREPLUMBER_DEBUG=5:wp-* WIREPLUMBER_DEBUG=D:wp-*
Show all messages from ``wp-registry``, libpipewire and all modules: Show all messages from ``wp-registry``, libpipewire and all modules:
.. code:: .. code::
WIREPLUMBER_DEBUG=5:wp-registry,pw,m-* WIREPLUMBER_DEBUG=D:wp-registry,pw,m-*
Relationship with the GLib log handler & G_MESSAGES_DEBUG Relationship with the GLib log handler & G_MESSAGES_DEBUG
--------------------------------------------------------- ---------------------------------------------------------
......
...@@ -379,6 +379,19 @@ wp_log_level_is_enabled (GLogLevelFlags log_level) ...@@ -379,6 +379,19 @@ wp_log_level_is_enabled (GLogLevelFlags log_level)
return log_level_index (log_level) <= enabled_level; return log_level_index (log_level) <= enabled_level;
} }
static gint
level_index_from_string (const char *str)
{
g_return_val_if_fail (str != NULL, 0);
for (guint i = 0; i < G_N_ELEMENTS (log_level_info); i++) {
if (g_str_equal (str, log_level_info[i].name))
return i;
}
return level_index_from_spa (atoi (str));
}
/*! /*!
* \brief Configures the log level and enabled categories * \brief Configures the log level and enabled categories
* \ingroup wplog * \ingroup wplog
...@@ -406,7 +419,7 @@ wp_log_set_level (const gchar * level_str) ...@@ -406,7 +419,7 @@ wp_log_set_level (const gchar * level_str)
tokens = pw_split_strv (level_str, ":", 2, &n_tokens); tokens = pw_split_strv (level_str, ":", 2, &n_tokens);
/* set the log level */ /* set the log level */
enabled_level = level_index_from_spa (atoi (tokens[0])); enabled_level = level_index_from_string (tokens[0]);
/* enable filtering of debug categories */ /* enable filtering of debug categories */
if (n_tokens > 1) { if (n_tokens > 1) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment