mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-04 01:32:42 +00:00
gstinfo: Reduce code duplication around level pattern matching
Move the match, logging and set_threshold to a new function. The log levels are different, so choose the higher one (LOG). Having two equivalent messages at two different levels seems like a bad idea anyway. https://bugzilla.gnome.org/show_bug.cgi?id=794717
This commit is contained in:
parent
8117a29408
commit
b12df466f2
1 changed files with 16 additions and 12 deletions
|
@ -1577,6 +1577,20 @@ gst_debug_get_default_threshold (void)
|
|||
return (GstDebugLevel) g_atomic_int_get (&__default_level);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_debug_apply_entry (GstDebugCategory * cat, LevelNameEntry * entry)
|
||||
{
|
||||
if (!g_pattern_match_string (entry->pat, cat->name))
|
||||
return FALSE;
|
||||
|
||||
if (gst_is_initialized ())
|
||||
GST_LOG ("category %s matches pattern %p - gets set to level %d",
|
||||
cat->name, entry->pat, entry->level);
|
||||
|
||||
gst_debug_category_set_threshold (cat, entry->level);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_debug_reset_threshold (gpointer category, gpointer unused)
|
||||
{
|
||||
|
@ -1589,14 +1603,9 @@ gst_debug_reset_threshold (gpointer category, gpointer unused)
|
|||
LevelNameEntry *entry = walk->data;
|
||||
|
||||
walk = g_slist_next (walk);
|
||||
if (g_pattern_match_string (entry->pat, cat->name)) {
|
||||
if (gst_is_initialized ())
|
||||
GST_LOG ("category %s matches pattern %p - gets set to level %d",
|
||||
cat->name, entry->pat, entry->level);
|
||||
gst_debug_category_set_threshold (cat, entry->level);
|
||||
if (gst_debug_apply_entry (cat, entry))
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
gst_debug_category_set_threshold (cat, gst_debug_get_default_threshold ());
|
||||
|
||||
exit:
|
||||
|
@ -1617,12 +1626,7 @@ for_each_threshold_by_entry (gpointer data, gpointer user_data)
|
|||
GstDebugCategory *cat = (GstDebugCategory *) data;
|
||||
LevelNameEntry *entry = (LevelNameEntry *) user_data;
|
||||
|
||||
if (g_pattern_match_string (entry->pat, cat->name)) {
|
||||
if (gst_is_initialized ())
|
||||
GST_TRACE ("category %s matches pattern %p - gets set to level %d",
|
||||
cat->name, entry->pat, entry->level);
|
||||
gst_debug_category_set_threshold (cat, entry->level);
|
||||
}
|
||||
gst_debug_apply_entry (cat, entry);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue