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:
parent
c2d125b0da
commit
4e17edb1ac
|
@ -299,8 +299,10 @@ wp_core_constructed (GObject *object)
|
|||
/* use the same config option as pipewire to set the log level */
|
||||
p = (struct pw_properties *) pw_context_get_properties (self->pw_context);
|
||||
if (!g_getenv("WIREPLUMBER_DEBUG") &&
|
||||
(str = pw_properties_get(p, "log.level")) != NULL)
|
||||
wp_log_set_global_level (str);
|
||||
(str = pw_properties_get(p, "log.level")) != NULL) {
|
||||
if (!wp_log_set_global_level (str))
|
||||
wp_warning ("ignoring invalid log.level in config file: %s", str);
|
||||
}
|
||||
|
||||
/* Init refcount */
|
||||
grefcount *rc = pw_context_get_user_data (self->pw_context);
|
||||
|
|
|
@ -410,8 +410,7 @@ wp_log_init (gint flags)
|
|||
}
|
||||
}
|
||||
|
||||
/* private, called from core.c when reading the config file */
|
||||
void
|
||||
gboolean
|
||||
wp_log_set_global_level (const gchar *log_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);
|
||||
wp_spa_log_get_instance()->level = level_index_to_spa (level);
|
||||
pw_log_set_level (level_index_to_spa (level));
|
||||
return TRUE;
|
||||
} else {
|
||||
wp_warning ("ignoring invalid log.level in config file: %s", log_level);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ G_BEGIN_DECLS
|
|||
WP_PRIVATE_API
|
||||
void wp_log_init (gint flags);
|
||||
|
||||
WP_PRIVATE_API
|
||||
void wp_log_set_global_level (const gchar *log_level);
|
||||
WP_API
|
||||
gboolean wp_log_set_global_level (const gchar *log_level);
|
||||
|
||||
typedef struct _WpLogTopic WpLogTopic;
|
||||
struct _WpLogTopic {
|
||||
|
|
Loading…
Reference in New Issue