From ee52459a5ed7e78f3796a4737374904194b5a5b1 Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Wed, 28 Dec 2016 21:47:03 +0100 Subject: [PATCH] info: re-eval GST_DEBUG env var for late categories When registering a new debug category after _debug_init(), we need to re check the GST_DEBUG filter settings again. In addition when parsing the filter setting, we need to already bump up the min-debug level to not suppress debug log statments that dynamically register a category. This happens in libraries that use a function to register a category on first use. --- gst/gstinfo.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/gst/gstinfo.c b/gst/gstinfo.c index 30ed264ae7..735caefa0f 100644 --- a/gst/gstinfo.c +++ b/gst/gstinfo.c @@ -239,6 +239,8 @@ dladdr (void *address, Dl_info * dl) #endif /* __sgi__ */ #endif +static const gchar *_gst_debug_filter = NULL; + static void gst_debug_reset_threshold (gpointer category, gpointer unused); static void gst_debug_reset_all_thresholds (void); @@ -461,9 +463,9 @@ _priv_gst_debug_init (void) if (env) gst_debug_set_color_mode_from_string (env); - env = g_getenv ("GST_DEBUG"); - if (env) { - gst_debug_set_threshold_from_string (env, FALSE); + _gst_debug_filter = g_getenv ("GST_DEBUG"); + if (_gst_debug_filter) { + gst_debug_set_threshold_from_string (_gst_debug_filter, FALSE); } } @@ -1721,6 +1723,11 @@ _gst_debug_category_new (const gchar * name, guint color, } g_mutex_unlock (&__cat_mutex); + /* ensure the filter is applied to categories registered after _debug_init */ + if (_gst_debug_filter) { + gst_debug_set_threshold_from_string (_gst_debug_filter, FALSE); + } + return cat; } @@ -1990,8 +1997,15 @@ gst_debug_set_threshold_from_string (const gchar * list, gboolean reset) const gchar *category; if (parse_debug_category (values[0], &category) - && parse_debug_level (values[1], &level)) + && parse_debug_level (values[1], &level)) { gst_debug_set_threshold_for_name (category, level); + + /* bump min-level anyway to allow the category to be registered in the + * future still */ + if (level > _gst_debug_min) { + _gst_debug_min = level; + } + } } g_strfreev (values);