wp: make wp_log_set_global_level public API

Applications may want to change WP log level at runtime.

Also change it to return error stataus instead of printing warnings on
error.
This commit is contained in:
Pauli Virtanen
2023-12-07 18:48:07 +02:00
committed by George Kiagiadakis
parent c2d125b0da
commit 4e17edb1ac
3 changed files with 9 additions and 7 deletions

View File

@@ -299,8 +299,10 @@ wp_core_constructed (GObject *object)
/* use the same config option as pipewire to set the log level */ /* use the same config option as pipewire to set the log level */
p = (struct pw_properties *) pw_context_get_properties (self->pw_context); p = (struct pw_properties *) pw_context_get_properties (self->pw_context);
if (!g_getenv("WIREPLUMBER_DEBUG") && if (!g_getenv("WIREPLUMBER_DEBUG") &&
(str = pw_properties_get(p, "log.level")) != NULL) (str = pw_properties_get(p, "log.level")) != NULL) {
wp_log_set_global_level (str); if (!wp_log_set_global_level (str))
wp_warning ("ignoring invalid log.level in config file: %s", str);
}
/* Init refcount */ /* Init refcount */
grefcount *rc = pw_context_get_user_data (self->pw_context); grefcount *rc = pw_context_get_user_data (self->pw_context);

View File

@@ -410,8 +410,7 @@ wp_log_init (gint flags)
} }
} }
/* private, called from core.c when reading the config file */ gboolean
void
wp_log_set_global_level (const gchar *log_level) wp_log_set_global_level (const gchar *log_level)
{ {
gint level; gint level;
@@ -420,8 +419,9 @@ wp_log_set_global_level (const gchar *log_level)
log_state.global_log_level_flags = level_index_to_full_flags (level); log_state.global_log_level_flags = level_index_to_full_flags (level);
wp_spa_log_get_instance()->level = level_index_to_spa (level); wp_spa_log_get_instance()->level = level_index_to_spa (level);
pw_log_set_level (level_index_to_spa (level)); pw_log_set_level (level_index_to_spa (level));
return TRUE;
} else { } else {
wp_warning ("ignoring invalid log.level in config file: %s", log_level); return FALSE;
} }
} }

View File

@@ -23,8 +23,8 @@ G_BEGIN_DECLS
WP_PRIVATE_API WP_PRIVATE_API
void wp_log_init (gint flags); void wp_log_init (gint flags);
WP_PRIVATE_API WP_API
void wp_log_set_global_level (const gchar *log_level); gboolean wp_log_set_global_level (const gchar *log_level);
typedef struct _WpLogTopic WpLogTopic; typedef struct _WpLogTopic WpLogTopic;
struct _WpLogTopic { struct _WpLogTopic {