mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-02-07 04:10:27 +01:00
debug: use levels 1-5 in WIREPLUMBER_DEBUG
This makes WIREPLUMBER_DEBUG behave just like PIPEWIRE_DEBUG. Same levels, same syntax, easier for users. ERROR & CRITICAL are always printed, as they should; there is no point in disabling them, since: - ERRORs are always fatal and should never ever happen - CRITICALs are assertion failures and indicate bugs that need to be fixed
This commit is contained in:
parent
a45d47f519
commit
5c8a462a4a
1 changed files with 11 additions and 9 deletions
|
|
@ -90,12 +90,15 @@ log_level_index (GLogLevelFlags log_level)
|
|||
}
|
||||
|
||||
static inline gint
|
||||
spa_log_level_index (enum spa_log_level lvl)
|
||||
level_index_from_spa (gint spa_lvl)
|
||||
{
|
||||
for (gint i = 1; i < SPA_N_ELEMENTS (log_level_info); i++)
|
||||
if (lvl == log_level_info[i].spa_level)
|
||||
return i;
|
||||
return 0;
|
||||
return CLAMP (spa_lvl + 2, 0, G_N_ELEMENTS (log_level_info) - 1);
|
||||
}
|
||||
|
||||
static inline gint
|
||||
level_index_to_spa (gint lvl_index)
|
||||
{
|
||||
return CLAMP (lvl_index - 2, 0, 5);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -113,8 +116,7 @@ wp_debug_initialize (void)
|
|||
tokens = pw_split_strv (debug, ":", 2, &n_tokens);
|
||||
|
||||
/* set the log level */
|
||||
enabled_level = atoi (tokens[0]);
|
||||
enabled_level = CLAMP (enabled_level, 0, G_N_ELEMENTS (log_level_info) - 1);
|
||||
enabled_level = level_index_from_spa (atoi (tokens[0]));
|
||||
|
||||
/* enable filtering of debug categories */
|
||||
if (n_tokens > 1) {
|
||||
|
|
@ -135,7 +137,7 @@ wp_debug_initialize (void)
|
|||
output_is_journal = g_log_writer_is_journald (fileno (stderr));
|
||||
|
||||
/* set the log level also on the spa_log */
|
||||
wp_spa_log_get_instance()->level = log_level_info[enabled_level].spa_level;
|
||||
wp_spa_log_get_instance()->level = level_index_to_spa (enabled_level);
|
||||
|
||||
if (categories)
|
||||
pw_free_strv (categories);
|
||||
|
|
@ -370,7 +372,7 @@ wp_spa_log_logv (void *object,
|
|||
{ "GLIB_DOMAIN", "pw", -1 },
|
||||
};
|
||||
|
||||
gint log_level_idx = spa_log_level_index (level);
|
||||
gint log_level_idx = level_index_from_spa (level);
|
||||
GLogLevelFlags log_level = log_level_info[log_level_idx].log_level;
|
||||
fields[0].value = log_level_info[log_level_idx].priority;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue