mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
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:
parent
0a21d76334
commit
e1672f9762
5 changed files with 67 additions and 10 deletions
|
|
@ -76,7 +76,7 @@ variable like so:
|
||||||
|
|
||||||
```
|
```
|
||||||
cd builddir/
|
cd builddir/
|
||||||
PIPEWIRE_DEBUG=4 make run
|
PIPEWIRE_DEBUG="D" make run
|
||||||
```
|
```
|
||||||
|
|
||||||
You might have to stop the pipewire service/socket that might have been
|
You might have to stop the pipewire service/socket that might have been
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,9 @@ or with the provided scripts shown below.
|
||||||
PipeWire can use environment variables to control the behaviour of
|
PipeWire can use environment variables to control the behaviour of
|
||||||
applications:
|
applications:
|
||||||
|
|
||||||
* `PIPEWIRE_DEBUG=<level>` to increase the debug level
|
* `PIPEWIRE_DEBUG=<level>` to increase the debug level (or use one of
|
||||||
|
`XEWIDT` for none, error, warnings, info,
|
||||||
|
debug, or trace, respectively).
|
||||||
* `PIPEWIRE_LOG=<filename>` to redirect log to filename
|
* `PIPEWIRE_LOG=<filename>` to redirect log to filename
|
||||||
* `PIPEWIRE_LOG_SYSTEMD=false` to disable logging to systemd journal
|
* `PIPEWIRE_LOG_SYSTEMD=false` to disable logging to systemd journal
|
||||||
* `PIPEWIRE_LATENCY=<num/denom>` to configure latency as a fraction. 10/1000
|
* `PIPEWIRE_LATENCY=<num/denom>` to configure latency as a fraction. 10/1000
|
||||||
|
|
|
||||||
|
|
@ -132,12 +132,12 @@ more debugging. The format is:
|
||||||
`<level>[<category>,<category>,...]`
|
`<level>[<category>,<category>,...]`
|
||||||
|
|
||||||
- `<level>` specifies the log level:
|
- `<level>` specifies the log level:
|
||||||
+ `0`: no logging is enabled
|
+ `X` or `0`: no logging is enabled
|
||||||
+ `1`: Error logging is enabled
|
+ `E` or `1`: Error logging is enabled
|
||||||
+ `2`: Warnings are enabled
|
+ `W` or `2`: Warnings are enabled
|
||||||
+ `3`: Informational messages are enabled
|
+ `I` or `3`: Informational messages are enabled
|
||||||
+ `4`: Debug messages are enabled
|
+ `D` or `4`: Debug messages are enabled
|
||||||
+ `5`: Trace messages are enabled. These messages can be logged
|
+ `T` or `5`: Trace messages are enabled. These messages can be logged
|
||||||
from the realtime threads.
|
from the realtime threads.
|
||||||
|
|
||||||
- `<category>`: Specifies a string category to enable. Many categories
|
- `<category>`: Specifies a string category to enable. Many categories
|
||||||
|
|
|
||||||
|
|
@ -215,8 +215,17 @@ static void configure_debug(struct support *support, const char *str)
|
||||||
int n_tokens;
|
int n_tokens;
|
||||||
|
|
||||||
level = pw_split_strv(str, ":", INT_MAX, &n_tokens);
|
level = pw_split_strv(str, ":", INT_MAX, &n_tokens);
|
||||||
if (n_tokens > 0)
|
if (n_tokens > 0) {
|
||||||
pw_log_set_level(atoi(level[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)
|
if (n_tokens > 1)
|
||||||
support->categories = pw_split_strv(level[1], ",", INT_MAX, &n_tokens);
|
support->categories = pw_split_strv(level[1], ",", INT_MAX, &n_tokens);
|
||||||
|
|
|
||||||
|
|
@ -243,6 +243,49 @@ PWTEST(logger_debug_env)
|
||||||
return PWTEST_PASS;
|
return PWTEST_PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PWTEST(logger_debug_env_alpha)
|
||||||
|
{
|
||||||
|
enum spa_log_level level = pwtest_get_iteration(current_test);
|
||||||
|
enum spa_log_level default_level = pw_log_level;
|
||||||
|
struct spa_log *default_logger = pw_log_get();
|
||||||
|
char *lvl;
|
||||||
|
char *oldenv = getenv("PIPEWIRE_DEBUG");
|
||||||
|
|
||||||
|
if (oldenv)
|
||||||
|
oldenv = strdup(oldenv);
|
||||||
|
|
||||||
|
switch(level) {
|
||||||
|
case SPA_LOG_LEVEL_NONE: lvl = "X"; break;
|
||||||
|
case SPA_LOG_LEVEL_ERROR: lvl = "E"; break;
|
||||||
|
case SPA_LOG_LEVEL_WARN: lvl = "W"; break;
|
||||||
|
case SPA_LOG_LEVEL_INFO: lvl = "I"; break;
|
||||||
|
case SPA_LOG_LEVEL_DEBUG: lvl = "D"; break;
|
||||||
|
case SPA_LOG_LEVEL_TRACE: lvl = "T"; break;
|
||||||
|
default:
|
||||||
|
pwtest_fail_if_reached();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
setenv("PIPEWIRE_DEBUG", lvl, 1);
|
||||||
|
|
||||||
|
/* Disable logging, let PIPEWIRE_DEBUG set the level */
|
||||||
|
pw_log_set_level(SPA_LOG_LEVEL_NONE);
|
||||||
|
|
||||||
|
test_log_levels(level);
|
||||||
|
|
||||||
|
if (oldenv) {
|
||||||
|
setenv("PIPEWIRE_DEBUG", oldenv, 1);
|
||||||
|
free(oldenv);
|
||||||
|
} else {
|
||||||
|
unsetenv("PIPEWIRE_DEBUG");
|
||||||
|
}
|
||||||
|
|
||||||
|
pw_log_set(default_logger);
|
||||||
|
pw_log_set_level(default_level);
|
||||||
|
pw_deinit();
|
||||||
|
|
||||||
|
return PWTEST_PASS;
|
||||||
|
}
|
||||||
|
|
||||||
PWTEST_SUITE(logger)
|
PWTEST_SUITE(logger)
|
||||||
{
|
{
|
||||||
pwtest_add(logger_truncate_long_lines, PWTEST_NOARG);
|
pwtest_add(logger_truncate_long_lines, PWTEST_NOARG);
|
||||||
|
|
@ -253,6 +296,9 @@ PWTEST_SUITE(logger)
|
||||||
pwtest_add(logger_debug_env,
|
pwtest_add(logger_debug_env,
|
||||||
PWTEST_ARG_RANGE, SPA_LOG_LEVEL_NONE, SPA_LOG_LEVEL_TRACE + 1,
|
PWTEST_ARG_RANGE, SPA_LOG_LEVEL_NONE, SPA_LOG_LEVEL_TRACE + 1,
|
||||||
PWTEST_NOARG);
|
PWTEST_NOARG);
|
||||||
|
pwtest_add(logger_debug_env_alpha,
|
||||||
|
PWTEST_ARG_RANGE, SPA_LOG_LEVEL_NONE, SPA_LOG_LEVEL_TRACE + 1,
|
||||||
|
PWTEST_NOARG);
|
||||||
|
|
||||||
return PWTEST_PASS;
|
return PWTEST_PASS;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue