validate: Keep trying to print stack traces when our log hanlder is removed

There are cases where a crash happens after the program ends
This commit is contained in:
Thibault Saunier 2019-02-01 00:08:45 -03:00
parent 68573ae919
commit ba9b2c5ec5

View file

@ -256,15 +256,29 @@ done:
g_free (message); g_free (message);
} }
static void
gst_validate_default_log_hanlder (const gchar * log_domain,
GLogLevelFlags log_level, const gchar * message, gpointer user_data)
{
gchar *trace = gst_debug_get_stack_trace (GST_STACK_TRACE_SHOW_FULL);
if (trace) {
g_print ("\nStack trace:\n%s\n", trace);
g_free (trace);
}
g_log_default_handler (log_domain, log_level, message, user_data);
}
static void static void
gst_validate_reporter_destroyed (gpointer udata, GObject * freed_reporter) gst_validate_reporter_destroyed (gpointer udata, GObject * freed_reporter)
{ {
g_log_set_handler ("GStreamer", g_log_set_handler ("GStreamer",
G_LOG_LEVEL_MASK, (GLogFunc) g_log_default_handler, NULL); G_LOG_LEVEL_MASK, (GLogFunc) gst_validate_default_log_hanlder, NULL);
g_log_set_handler ("GLib", g_log_set_handler ("GLib",
G_LOG_LEVEL_MASK, (GLogFunc) g_log_default_handler, NULL); G_LOG_LEVEL_MASK, (GLogFunc) gst_validate_default_log_hanlder, NULL);
g_log_set_handler ("GLib-GObject", g_log_set_handler ("GLib-GObject",
G_LOG_LEVEL_MASK, (GLogFunc) g_log_default_handler, NULL); G_LOG_LEVEL_MASK, (GLogFunc) gst_validate_default_log_hanlder, NULL);
} }
static void static void