gint main (gint argc, gchar * argv[]) { GSList *before, *after; unsetenv ("GST_DEBUG"); gst_init (&argc, &argv); before = gst_debug_get_all_categories (); GST_DEBUG_CATEGORY_INIT (cat, "cat", GST_DEBUG_FG_GREEN, "default category for this test"); GST_DEBUG_CATEGORY_INIT (cat_static, "cat_static", GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE | GST_DEBUG_BG_RED, "static category for this test"); after = gst_debug_get_all_categories (); g_print ("removing default log function\n"); #ifdef GST_DISABLE_GST_DEBUG g_assert (gst_debug_remove_log_function (gst_debug_log_default) == 0); #else g_assert (gst_debug_remove_log_function (gst_debug_log_default) == 1); g_print ("checking, if the two new categories are put into the category list correctly...\n"); g_assert (g_slist_length (after) - g_slist_length (before) == 2); /* check the _get stuff */ g_print ("checking, if the gst_debug_category_get_* stuff works with the categories...\n"); g_assert (strcmp (gst_debug_category_get_name (cat), "cat") == 0); g_assert (gst_debug_category_get_color (cat) == GST_DEBUG_FG_GREEN); g_assert (strcmp (gst_debug_category_get_description (cat), "default category for this test") == 0); g_assert (gst_debug_category_get_threshold (cat) == gst_debug_get_default_threshold ()); g_assert (strcmp (gst_debug_category_get_name (cat_static), "cat_static") == 0); g_assert (gst_debug_category_get_color (cat_static) | GST_DEBUG_FG_GREEN); g_assert (gst_debug_category_get_color (cat_static) | GST_DEBUG_BG_RED); g_assert (gst_debug_category_get_color (cat_static) | GST_DEBUG_BOLD); g_assert (strcmp (gst_debug_category_get_description (cat_static), "static category for this test") == 0); g_assert (gst_debug_category_get_threshold (cat_static) == gst_debug_get_default_threshold ()); /* check if setting levels for names work */ g_print ("checking if changing threshold for names affects existing categories...\n"); gst_debug_set_threshold_for_name ("cat", GST_LEVEL_DEBUG); g_assert (gst_debug_category_get_threshold (cat) == GST_LEVEL_DEBUG); g_assert (gst_debug_category_get_threshold (cat_static) == gst_debug_get_default_threshold ()); gst_debug_set_threshold_for_name ("cat_static", GST_LEVEL_INFO); g_assert (gst_debug_category_get_threshold (cat) == GST_LEVEL_DEBUG); g_assert (gst_debug_category_get_threshold (cat_static) == GST_LEVEL_INFO); #endif g_print ("everything ok.\n"); return 0; }
void gst_debugserver_log_send_debug_categories (GstDebugserverTcp * tcp_server, TcpClient * client) { GstDebugger__GStreamerData gst_data = GST_DEBUGGER__GSTREAMER_DATA__INIT; GstDebugger__DebugCategories debug_categories = GST_DEBUGGER__DEBUG_CATEGORIES__INIT; gint categories_count, i = 0; gst_data.info_type_case = GST_DEBUGGER__GSTREAMER_DATA__INFO_TYPE_DEBUG_CATEGORIES; GSList *tmp, *all_categories = gst_debug_get_all_categories (); tmp = all_categories = g_slist_sort (all_categories, sort_by_category_name); categories_count = g_slist_length (all_categories); debug_categories.n_category = categories_count; debug_categories.category = (char **) g_malloc (sizeof (char *) * categories_count); while (tmp) { GstDebugCategory *cat = (GstDebugCategory *) tmp->data; debug_categories.category[i++] = (char *) gst_debug_category_get_name (cat); tmp = g_slist_next (tmp); } g_slist_free (all_categories); gst_data.debug_categories = &debug_categories; gst_debugserver_tcp_send_packet (tcp_server, client, &gst_data); g_free (debug_categories.category); }
void gst_debugserver_log_send_log (GstDebugserverLog * log, GstDebugserverTcp * tcp_server, GstDebugCategory * category, GstDebugLevel level, const gchar * file, const gchar * function, gint line, GObject * object, GstDebugMessage * message) { GstDebugger__GStreamerData gst_data = GST_DEBUGGER__GSTREAMER_DATA__INIT; GstDebugger__LogInfo log_info = GST_DEBUGGER__LOG_INFO__INIT; log_info.level = (gint) level; log_info.category = (gchar *) gst_debug_category_get_name (category); log_info.file = (gchar *) file; log_info.function = (gchar *) function; log_info.line = line; if (GST_IS_OBJECT (object)) { log_info.object = GST_OBJECT_NAME (object); } else { log_info.object = (gchar *) G_OBJECT_TYPE_NAME (object); } log_info.message = (gchar *) gst_debug_message_get (message); gst_data.info_type_case = GST_DEBUGGER__GSTREAMER_DATA__INFO_TYPE_LOG_INFO; gst_data.log_info = &log_info; gst_debugserver_hooks_send_data (&log->hooks, tcp_server, &gst_data); }
static void gst_log_android_handler(GstDebugCategory *category, GstDebugLevel level, const gchar *file, const gchar *function, gint line, GObject *object, GstDebugMessage *message, gpointer data) { gchar *obj = NULL; OWR_UNUSED(data); if (level > gst_debug_category_get_threshold(category)) return; if (GST_IS_PAD(object) && GST_OBJECT_NAME(object)) { obj = g_strdup_printf("<%s:%s>", GST_DEBUG_PAD_NAME(object)); } else if (GST_IS_OBJECT(object)) { obj = g_strdup_printf("<%s>", GST_OBJECT_NAME(object)); } __android_log_print(ANDROID_LOG_INFO, "gst_log", "%p %s %s %s:%d:%s:%s %s\n", (void *)g_thread_self(), gst_debug_level_get_name(level), gst_debug_category_get_name(category), file, line, function, obj ? obj : "", gst_debug_message_get(message)); g_free(obj); }
static void check_gst_log_handler (GstDebugCategory * category, GstDebugLevel level, const gchar * file, const gchar * function, gint line, GObject * object, GstDebugMessage * _message, gpointer data) { const gchar *message = gst_debug_message_get (_message); gchar *msg, *obj_str; const gchar *level_str, *cat_str; GstClockTime elapsed; //-- check message contents if (__check_method && (strstr (function, __check_method) != NULL) && __check_test && (strstr (message, __check_test) != NULL)) __check_error_trapped = TRUE; else if (__check_method && (strstr (function, __check_method) != NULL) && !__check_test) __check_error_trapped = TRUE; else if (__check_test && (strstr (message, __check_test) != NULL) && !__check_method) __check_error_trapped = TRUE; if (level > gst_debug_category_get_threshold (category)) return; elapsed = GST_CLOCK_DIFF (_priv_bt_info_start_time, gst_util_get_timestamp ()); level_str = gst_debug_level_get_name (level); cat_str = gst_debug_category_get_name (category); if (object) { if (GST_IS_OBJECT (object)) { obj_str = g_strdup_printf ("<%s,%" G_OBJECT_REF_COUNT_FMT ">", GST_OBJECT_NAME (object), G_OBJECT_LOG_REF_COUNT (object)); } else if (GST_IS_OBJECT (object)) { obj_str = g_strdup_printf ("<%s,%" G_OBJECT_REF_COUNT_FMT ">", G_OBJECT_TYPE_NAME (object), G_OBJECT_LOG_REF_COUNT (object)); } else { obj_str = g_strdup_printf ("%p", object); } } else { obj_str = g_strdup (""); } msg = g_alloca (95 + strlen (cat_str) + strlen (level_str) + strlen (message) + strlen (file) + strlen (function) + strlen (obj_str)); g_sprintf (msg, "%" GST_TIME_FORMAT " %" PID_FMT " %" PTR_FMT " %-7s %20s %s:%d:%s:%s %s", GST_TIME_ARGS (elapsed), getpid (), g_thread_self (), level_str, cat_str, file, line, function, obj_str, message); g_free (obj_str); check_print_handler (msg); }
static void log_func (GstDebugCategory *category, GstDebugLevel level, const gchar *file, const gchar *function, gint line, GObject *object, GstDebugMessage *message, gpointer user_data) { Log *log = (Log *)user_data; GDateTime *datetime; gchar *date; const gchar *cat; if (level > gst_debug_category_get_threshold (category)) { return; } cat = gst_debug_category_get_name (category); datetime = g_date_time_new_now_local (); if (g_strcmp0 (cat, "access") == 0) { date = g_date_time_format (datetime, "%b/%d/%Y:%H:%M:%S %z"); fprintf (log->access_hd, gst_debug_message_get (message), date); g_free (date); fflush (log->access_hd); } else { date = g_date_time_format (datetime, "%b %d %H:%M:%S"); fprintf (log->log_hd, "%s.%d %s" CAT_FMT "%s\n", date, g_date_time_get_microsecond (datetime), gst_debug_level_get_name (level), cat, file, line, gst_debug_message_get (message)); g_free (date); fflush (log->log_hd); } g_date_time_unref (datetime); }
void LLMediaImplGStreamer::gstreamer_log(GstDebugCategory *category, GstDebugLevel level, const gchar *file, const gchar *function, gint line, GObject *object, GstDebugMessage *message, gpointer data) { std::stringstream log(std::stringstream::out); // Log format example: // // GST_ELEMENT_PADS: removing pad 'sink' (in gstelement.c:757:gst_element_remove_pad) // log << gst_debug_category_get_name( category ) << ": " << gst_debug_message_get(message) << " " << "(in " << file << ":" << line << ":" << function << ")"; switch( level ) { case GST_LEVEL_ERROR: LL_WARNS("MediaImpl") << "(ERROR) " << log.str() << LL_ENDL; break; case GST_LEVEL_WARNING: LL_WARNS("MediaImpl") << log.str() << LL_ENDL; break; case GST_LEVEL_DEBUG: LL_DEBUGS("MediaImpl") << log.str() << LL_ENDL; break; case GST_LEVEL_INFO: LL_INFOS("MediaImpl") << log.str() << LL_ENDL; break; default: // Do nothing. break; } }
static void gst_debug_help (void) { GSList *list, *walk; GList *list2, *g; /* Need to ensure the registry is loaded to get debug categories */ if (!init_post (NULL, NULL, NULL, NULL)) exit (1); list2 = gst_registry_plugin_filter (gst_registry_get (), select_all, FALSE, NULL); /* FIXME this is gross. why don't debug have categories PluginFeatures? */ for (g = list2; g; g = g_list_next (g)) { GstPlugin *plugin = GST_PLUGIN_CAST (g->data); gst_plugin_load (plugin); } g_list_free (list2); list = gst_debug_get_all_categories (); walk = list = g_slist_sort (list, sort_by_category_name); g_print ("\n"); g_print ("name level description\n"); g_print ("---------------------+--------+--------------------------------\n"); while (walk) { gboolean on_unix; GstDebugCategory *cat = (GstDebugCategory *) walk->data; GstDebugColorMode coloring = gst_debug_get_color_mode (); #ifdef G_OS_UNIX on_unix = TRUE; #else on_unix = FALSE; #endif if (GST_DEBUG_COLOR_MODE_UNIX == coloring || (on_unix && GST_DEBUG_COLOR_MODE_ON == coloring)) { gchar *color = gst_debug_construct_term_color (cat->color); g_print ("%s%-20s\033[00m %1d %s %s%s\033[00m\n", color, gst_debug_category_get_name (cat), gst_debug_category_get_threshold (cat), gst_debug_level_get_name (gst_debug_category_get_threshold (cat)), color, gst_debug_category_get_description (cat)); g_free (color); } else if (GST_DEBUG_COLOR_MODE_ON == coloring && !on_unix) { #ifdef G_OS_WIN32 gint color = gst_debug_construct_win_color (cat->color); const gint clear = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), color); g_print ("%-20s", gst_debug_category_get_name (cat)); SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), clear); g_print (" %1d %s ", gst_debug_category_get_threshold (cat), gst_debug_level_get_name (gst_debug_category_get_threshold (cat))); SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), color); g_print ("%s", gst_debug_category_get_description (cat)); SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), clear); g_print ("\n"); #endif /* G_OS_WIN32 */ } else { g_print ("%-20s %1d %s %s\n", gst_debug_category_get_name (cat), gst_debug_category_get_threshold (cat), gst_debug_level_get_name (gst_debug_category_get_threshold (cat)), gst_debug_category_get_description (cat)); } walk = g_slist_next (walk); } g_slist_free (list); g_print ("\n"); }
static gint sort_by_category_name (gconstpointer a, gconstpointer b) { return strcmp (gst_debug_category_get_name ((GstDebugCategory *) a), gst_debug_category_get_name ((GstDebugCategory *) b)); }
static void gst_debug_gub(GstDebugCategory * category, GstDebugLevel level, const gchar * file, const gchar * function, gint line, GObject * object, GstDebugMessage * message, gpointer unused) { GstClockTime elapsed; gchar *tag; const gchar *level_str; if (level > gst_debug_category_get_threshold(category)) return; elapsed = GST_CLOCK_DIFF(_priv_gst_info_start_time, gst_util_get_timestamp()); switch (level) { case GST_LEVEL_ERROR: level_str = "ERR"; break; case GST_LEVEL_WARNING: level_str = "WRN"; break; case GST_LEVEL_INFO: level_str = "NFO"; break; case GST_LEVEL_DEBUG: level_str = "DBG"; break; default: level_str = "LOG"; break; } tag = g_strdup_printf("%s", gst_debug_category_get_name(category)); if (object) { gchar *obj; if (GST_IS_PAD(object) && GST_OBJECT_NAME(object)) { obj = g_strdup_printf("<%s:%s>", GST_DEBUG_PAD_NAME(object)); } else if (GST_IS_OBJECT(object) && GST_OBJECT_NAME(object)) { obj = g_strdup_printf("<%s>", GST_OBJECT_NAME(object)); } else if (G_IS_OBJECT(object)) { obj = g_strdup_printf("<%s@%p>", G_OBJECT_TYPE_NAME(object), object); } else { obj = g_strdup_printf("<%p>", object); } gub_log( "%" GST_TIME_FORMAT " %p %s %s %s:%d:%s:%s %s", GST_TIME_ARGS(elapsed), g_thread_self(), level_str, tag, file, line, function, obj, gst_debug_message_get(message)); g_free(obj); } else { gub_log( "%" GST_TIME_FORMAT " %p %s %s %s:%d:%s %s", GST_TIME_ARGS(elapsed), g_thread_self(), level_str, tag, file, line, function, gst_debug_message_get(message)); } g_free(tag); }