pipewire: allow for log level names in PIPEWIRE_DEBUG

Allow one of "XEWIDT" to refer to none, errors, warnings, info, debug
and trace, respectively because they're immediately recognizable. Well,
except maybe the X.

PIPEWIRE_DEBUG="I" is equivalent to PIPEWIRE_DEBUG="3" for example.
This commit is contained in:
Peter Hutterer 2021-09-10 08:51:52 +10:00 committed by Wim Taymans
parent 0a21d76334
commit e1672f9762
5 changed files with 67 additions and 10 deletions

View file

@ -215,8 +215,17 @@ static void configure_debug(struct support *support, const char *str)
int n_tokens;
level = pw_split_strv(str, ":", INT_MAX, &n_tokens);
if (n_tokens > 0)
pw_log_set_level(atoi(level[0]));
if (n_tokens > 0) {
switch (level[0][0]) {
case 'X': pw_log_set_level(SPA_LOG_LEVEL_NONE); break;
case 'E': pw_log_set_level(SPA_LOG_LEVEL_ERROR); break;
case 'W': pw_log_set_level(SPA_LOG_LEVEL_WARN); break;
case 'I': pw_log_set_level(SPA_LOG_LEVEL_INFO); break;
case 'D': pw_log_set_level(SPA_LOG_LEVEL_DEBUG); break;
case 'T': pw_log_set_level(SPA_LOG_LEVEL_TRACE); break;
default: pw_log_set_level(atoi(level[0])); break;
}
}
if (n_tokens > 1)
support->categories = pw_split_strv(level[1], ",", INT_MAX, &n_tokens);