mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 06:46:38 +00:00
validate: Handle g_log errors at the gst-validate level
This commit is contained in:
parent
8899ad004c
commit
ad25b4d160
6 changed files with 44 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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_ */
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue