diff --git a/validate/gst/validate/gst-validate-report.c b/validate/gst/validate/gst-validate-report.c index 66326e1c5b..766d65cc5b 100644 --- a/validate/gst/validate/gst-validate-report.c +++ b/validate/gst/validate/gst-validate-report.c @@ -213,6 +213,11 @@ gst_validate_report_load_issues (void) REGISTER_VALIDATE_ISSUE (CRITICAL, SCENARIO_ACTION_EXECUTION_ERROR, _("The execution of an action did not properly happen"), NULL); + REGISTER_VALIDATE_ISSUE (WARNING, G_LOG_WARNING, _("We got a g_log warning"), + NULL); + REGISTER_VALIDATE_ISSUE (WARNING, G_LOG_CRITICAL, + _("We got a g_log critical issue"), NULL); + REGISTER_VALIDATE_ISSUE (ISSUE, G_LOG_ISSUE, _("We got a g_log issue"), NULL); } void diff --git a/validate/gst/validate/gst-validate-report.h b/validate/gst/validate/gst-validate-report.h index 756d3db719..ce39585909 100644 --- a/validate/gst/validate/gst-validate-report.h +++ b/validate/gst/validate/gst-validate-report.h @@ -113,6 +113,10 @@ typedef enum { #define GST_VALIDATE_ISSUE_ID_SCENARIO_NOT_ENDED (((GstValidateIssueId) GST_VALIDATE_AREA_SCENARIO) << GST_VALIDATE_ISSUE_ID_SHIFT | 1) #define GST_VALIDATE_ISSUE_ID_SCENARIO_ACTION_EXECUTION_ERROR (((GstValidateIssueId) GST_VALIDATE_AREA_SCENARIO) << GST_VALIDATE_ISSUE_ID_SHIFT | 2) +#define GST_VALIDATE_ISSUE_ID_G_LOG_ISSUE (((GstValidateIssueId) GST_VALIDATE_AREA_OTHER) << GST_VALIDATE_ISSUE_ID_SHIFT | 1) +#define GST_VALIDATE_ISSUE_ID_G_LOG_WARNING (((GstValidateIssueId) GST_VALIDATE_AREA_OTHER) << GST_VALIDATE_ISSUE_ID_SHIFT | 2) +#define GST_VALIDATE_ISSUE_ID_G_LOG_CRITICAL (((GstValidateIssueId) GST_VALIDATE_AREA_OTHER) << GST_VALIDATE_ISSUE_ID_SHIFT | 3) + #define GST_VALIDATE_ISSUE_ID_AREA(id) ((guintptr)(id >> GST_VALIDATE_ISSUE_ID_SHIFT)) typedef struct { diff --git a/validate/gst/validate/gst-validate-reporter.c b/validate/gst/validate/gst-validate-reporter.c index d2283447fc..fe69de75c7 100644 --- a/validate/gst/validate/gst-validate-reporter.c +++ b/validate/gst/validate/gst-validate-reporter.c @@ -35,8 +35,11 @@ typedef struct _GstValidateReporterPrivate GstValidateRunner *runner; GHashTable *reports; char *name; + guint log_handler_id; } GstValidateReporterPrivate; +static GstValidateReporterPrivate * g_log_handler = NULL; + G_DEFINE_INTERFACE (GstValidateReporter, gst_validate_reporter, G_TYPE_OBJECT); static void @@ -52,6 +55,12 @@ gst_validate_reporter_default_init (GstValidateReporterInterface * iface) static void _free_priv (GstValidateReporterPrivate * priv) { + + if (g_log_handler == priv) { + g_log_set_default_handler (g_log_default_handler, NULL); + g_log_handler = NULL; + } + g_hash_table_unref (priv->reports); g_free (priv->name); g_slice_free (GstValidateReporterPrivate, priv); @@ -118,7 +127,7 @@ gst_validate_report_valist (GstValidateReporter * reporter, } g_hash_table_insert (priv->reports, (gpointer) issue_id, - gst_validate_report_ref (report)); + gst_validate_report_ref (report)); } combo = @@ -153,6 +162,19 @@ gst_validate_report_valist (GstValidateReporter * reporter, g_free (message); } +static void +gst_validate_reporter_g_log_func (const gchar * log_domain, + GLogLevelFlags log_level, const gchar * message, + GstValidateReporter * reporter) +{ + if (log_level & G_LOG_LEVEL_CRITICAL) + GST_VALIDATE_REPORT (reporter, G_LOG_CRITICAL, message); + else if (log_level & G_LOG_LEVEL_WARNING) + GST_VALIDATE_REPORT (reporter, G_LOG_WARNING, message); + else + GST_VALIDATE_REPORT (reporter, G_LOG_ISSUE, message); +} + void gst_validate_report (GstValidateReporter * reporter, GstValidateIssueId issue_id, const gchar * format, ...) @@ -199,3 +221,11 @@ gst_validate_reporter_set_runner (GstValidateReporter * reporter, priv->runner = runner; } + +void +gst_validate_reporter_set_handle_g_logs (GstValidateReporter * reporter) +{ + g_log_set_default_handler ((GLogFunc) gst_validate_reporter_g_log_func, reporter); + + g_log_handler = gst_validate_reporter_get_priv (reporter); +} diff --git a/validate/gst/validate/gst-validate-reporter.h b/validate/gst/validate/gst-validate-reporter.h index c86ea61025..fad2467412 100644 --- a/validate/gst/validate/gst-validate-reporter.h +++ b/validate/gst/validate/gst-validate-reporter.h @@ -77,8 +77,8 @@ void gst_validate_report (GstValidateReporter * reporter, void gst_validate_report_valist (GstValidateReporter * reporter, GstValidateIssueId issue_id, const gchar * format, va_list var_args); -void gst_validate_reporter_set_runner (GstValidateReporter * reporter, - GstValidateRunner *runner); +void gst_validate_reporter_set_runner (GstValidateReporter * reporter, GstValidateRunner *runner); +void gst_validate_reporter_set_handle_g_logs (GstValidateReporter * reporter); G_END_DECLS #endif /* _GST_VALIDATE_REPORTER_ */ diff --git a/validate/tools/gst-validate-transcoding.c b/validate/tools/gst-validate-transcoding.c index c21092c4f9..aaae220f9a 100644 --- a/validate/tools/gst-validate-transcoding.c +++ b/validate/tools/gst-validate-transcoding.c @@ -870,6 +870,7 @@ main (int argc, gchar ** argv) monitor = gst_validate_monitor_factory_create (GST_OBJECT_CAST (pipeline), runner, NULL); + gst_validate_reporter_set_handle_g_logs (GST_VALIDATE_REPORTER (monitor)); mainloop = g_main_loop_new (NULL, FALSE); if (!runner) { diff --git a/validate/tools/gst-validate.c b/validate/tools/gst-validate.c index e02d3e96b6..4891239887 100644 --- a/validate/tools/gst-validate.c +++ b/validate/tools/gst-validate.c @@ -278,6 +278,7 @@ main (int argc, gchar ** argv) monitor = gst_validate_monitor_factory_create (GST_OBJECT_CAST (pipeline), runner, NULL); + gst_validate_reporter_set_handle_g_logs (GST_VALIDATE_REPORTER (monitor)); mainloop = g_main_loop_new (NULL, FALSE); if (!runner) {