mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-09 07:28:41 +02:00
debug: honor WIREPLUMBER_DEBUG and ignore PIPEWIRE_DEBUG in pw_log
And also provide a way to disable this integration at runtime to get pipewire's log back, with WIREPLUMBER_NO_PW_LOG=1
This commit is contained in:
parent
17c1eb3fac
commit
bfe76bf1d1
2 changed files with 18 additions and 6 deletions
|
|
@ -109,11 +109,12 @@ wp_debug_initialize (void)
|
|||
|
||||
debug = g_getenv ("WIREPLUMBER_DEBUG");
|
||||
if (debug && debug[0] != '\0') {
|
||||
/* WP_DEBUG=level:category1,category2 */
|
||||
/* WIREPLUMBER_DEBUG=level:category1,category2 */
|
||||
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);
|
||||
|
||||
/* enable filtering of debug categories */
|
||||
if (n_tokens > 1) {
|
||||
|
|
@ -133,6 +134,9 @@ wp_debug_initialize (void)
|
|||
use_color = g_log_writer_supports_color (fileno (stderr));
|
||||
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;
|
||||
|
||||
if (categories)
|
||||
pw_free_strv (categories);
|
||||
if (tokens)
|
||||
|
|
@ -363,7 +367,7 @@ wp_spa_log_logv (void *object,
|
|||
{ "CODE_LINE", line_str, -1 },
|
||||
{ "CODE_FUNC", func, -1 },
|
||||
{ "MESSAGE", NULL, -1 },
|
||||
{ "GLIB_DOMAIN", "pw-lib", -1 },
|
||||
{ "GLIB_DOMAIN", "pw", -1 },
|
||||
};
|
||||
|
||||
gint log_level_idx = spa_log_level_index (level);
|
||||
|
|
@ -398,7 +402,7 @@ static const struct spa_log_methods wp_spa_log_methods = {
|
|||
|
||||
static struct spa_log wp_spa_log = {
|
||||
.iface = { SPA_TYPE_INTERFACE_Log, SPA_VERSION_LOG, { &wp_spa_log_methods, NULL } },
|
||||
.level = SPA_LOG_LEVEL_INFO,
|
||||
.level = SPA_LOG_LEVEL_WARN,
|
||||
};
|
||||
|
||||
struct spa_log *
|
||||
|
|
|
|||
14
lib/wp/wp.c
14
lib/wp/wp.c
|
|
@ -42,18 +42,26 @@
|
|||
void
|
||||
wp_init (WpInitFlags flags)
|
||||
{
|
||||
if (flags & WP_INIT_SET_PW_LOG)
|
||||
pw_log_set (wp_spa_log_get_instance ());
|
||||
enum spa_log_level lvl = 0;
|
||||
|
||||
if (flags & WP_INIT_SET_GLIB_LOG)
|
||||
g_log_set_writer_func (wp_log_writer_default, NULL, NULL);
|
||||
|
||||
/* a dummy message, to initialize the logging system */
|
||||
wp_message ("WirePlumber initializing");
|
||||
wp_info ("WirePlumber initializing");
|
||||
|
||||
if (flags & WP_INIT_SET_PW_LOG && !g_getenv ("WIREPLUMBER_NO_PW_LOG")) {
|
||||
pw_log_level = lvl = wp_spa_log_get_instance ()->level;
|
||||
pw_log_set (wp_spa_log_get_instance ());
|
||||
}
|
||||
|
||||
if (flags & WP_INIT_PIPEWIRE)
|
||||
pw_init (NULL, NULL);
|
||||
|
||||
/* restore our log level to override PIPEWIRE_DEBUG */
|
||||
if (flags & WP_INIT_SET_PW_LOG && !g_getenv ("WIREPLUMBER_NO_PW_LOG"))
|
||||
pw_log_set_level (lvl);
|
||||
|
||||
if (flags & WP_INIT_SPA_TYPES) {
|
||||
wp_spa_type_init (TRUE);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue