From 8518e08dbbf634520d8c4173899c820cb31b09c2 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Sat, 26 Jul 2014 11:41:09 +0200 Subject: [PATCH] validate: Add a way to avoid printing all the issue in reports Avoiding user to be flooded by information he does not want while debugging --- validate/gst/validate/gst-validate-report.c | 30 +++++++++++++++++++-- validate/gst/validate/gst-validate-report.h | 6 ++++- validate/gst/validate/gst-validate-runner.c | 5 +++- validate/gst/validate/gst-validate-runner.h | 1 + 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/validate/gst/validate/gst-validate-report.c b/validate/gst/validate/gst-validate-report.c index 91bb606a2e..e7f86c916b 100644 --- a/validate/gst/validate/gst-validate-report.c +++ b/validate/gst/validate/gst-validate-report.c @@ -252,7 +252,10 @@ gst_validate_report_init (void) const GDebugKey keys[] = { {"fatal_criticals", GST_VALIDATE_FATAL_CRITICALS}, {"fatal_warnings", GST_VALIDATE_FATAL_WARNINGS}, - {"fatal_issues", GST_VALIDATE_FATAL_ISSUES} + {"fatal_issues", GST_VALIDATE_FATAL_ISSUES}, + {"print_issues", GST_VALIDATE_PRINT_ISSUES}, + {"print_warnings", GST_VALIDATE_PRINT_WARNINGS}, + {"print_criticals", GST_VALIDATE_PRINT_CRITICALS} }; GST_DEBUG_CATEGORY_INIT (gst_validate_report_debug, "gstvalidatereport", @@ -264,7 +267,8 @@ gst_validate_report_init (void) /* init the debug flags */ var = g_getenv ("GST_VALIDATE"); if (var && strlen (var) > 0) { - _gst_validate_flags = g_parse_debug_string (var, keys, 3); + _gst_validate_flags = + g_parse_debug_string (var, keys, G_N_ELEMENTS (keys)); } gst_validate_report_load_issues (); @@ -341,6 +345,28 @@ gst_validate_report_area_get_name (GstValidateReportArea area) } } +gboolean +gst_validate_report_should_print (GstValidateReport * report) +{ + if ((!(_gst_validate_flags & GST_VALIDATE_PRINT_ISSUES) && + !(_gst_validate_flags & GST_VALIDATE_PRINT_WARNINGS) && + !(_gst_validate_flags & GST_VALIDATE_PRINT_CRITICALS))) { + return TRUE; + } + + if ((report->level <= GST_VALIDATE_REPORT_LEVEL_ISSUE && + _gst_validate_flags & GST_VALIDATE_PRINT_ISSUES) || + (report->level <= GST_VALIDATE_REPORT_LEVEL_WARNING && + _gst_validate_flags & GST_VALIDATE_PRINT_WARNINGS) || + (report->level <= GST_VALIDATE_REPORT_LEVEL_CRITICAL && + _gst_validate_flags & GST_VALIDATE_PRINT_CRITICALS)) { + + return TRUE; + } + + return FALSE; +} + gboolean gst_validate_report_check_abort (GstValidateReport * report) { diff --git a/validate/gst/validate/gst-validate-report.h b/validate/gst/validate/gst-validate-report.h index a43d8a2add..942c71e7af 100644 --- a/validate/gst/validate/gst-validate-report.h +++ b/validate/gst/validate/gst-validate-report.h @@ -39,7 +39,10 @@ typedef enum { GST_VALIDATE_FATAL_DEFAULT = 0, GST_VALIDATE_FATAL_ISSUES = 1 << 0, GST_VALIDATE_FATAL_WARNINGS = 1 << 1, - GST_VALIDATE_FATAL_CRITICALS = 1 << 2 + GST_VALIDATE_FATAL_CRITICALS = 1 << 2, + GST_VALIDATE_PRINT_ISSUES = 1 << 3, + GST_VALIDATE_PRINT_WARNINGS = 1 << 4, + GST_VALIDATE_PRINT_CRITICALS = 1 << 5 } GstValidateDebugFlags; typedef enum { @@ -208,6 +211,7 @@ void gst_validate_printf (gpointer source, void gst_validate_printf_valist (gpointer source, const gchar * format, va_list args) G_GNUC_NO_INSTRUMENT; +gboolean gst_validate_report_should_print (GstValidateReport * report); G_END_DECLS diff --git a/validate/gst/validate/gst-validate-runner.c b/validate/gst/validate/gst-validate-runner.c index 5470086ebf..bb1cb4ea12 100644 --- a/validate/gst/validate/gst-validate-runner.c +++ b/validate/gst/validate/gst-validate-runner.c @@ -81,6 +81,7 @@ static void gst_validate_runner_init (GstValidateRunner * runner) { runner->setup = FALSE; + runner->max_printed_level = GST_VALIDATE_REPORT_LEVEL_NUM_ENTRIES; } /** @@ -127,7 +128,9 @@ gst_validate_runner_printf (GstValidateRunner * runner) for (tmp = gst_validate_runner_get_reports (runner); tmp; tmp = tmp->next) { GstValidateReport *report = tmp->data; - gst_validate_report_printf (report); + if (gst_validate_report_should_print (report)) + gst_validate_report_printf (report); + if (ret == 0 && report->level == GST_VALIDATE_REPORT_LEVEL_CRITICAL) { criticals = g_list_append (criticals, tmp->data); ret = 18; diff --git a/validate/gst/validate/gst-validate-runner.h b/validate/gst/validate/gst-validate-runner.h index 73803a966a..76da09b922 100644 --- a/validate/gst/validate/gst-validate-runner.h +++ b/validate/gst/validate/gst-validate-runner.h @@ -53,6 +53,7 @@ struct _GstValidateRunner { GObject object; gboolean setup; + guint max_printed_level; /*< private >*/ GSList *reports;