mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-13 20:06:35 +00:00
added colorization of DEBUG and INFO, and a comment in gstelement.h
Original commit message from CVS: added colorization of DEBUG and INFO, and a comment in gstelement.h
This commit is contained in:
parent
89a89a8665
commit
41ca38a36d
6 changed files with 124 additions and 9 deletions
|
@ -43,3 +43,4 @@
|
||||||
#undef GST_INFO_ENABLED
|
#undef GST_INFO_ENABLED
|
||||||
#undef GST_INFO_ENABLED_VERBOSE
|
#undef GST_INFO_ENABLED_VERBOSE
|
||||||
#undef GST_INFO_FORCE_DISABLE
|
#undef GST_INFO_FORCE_DISABLE
|
||||||
|
#undef GST_DEBUG_COLOR
|
||||||
|
|
13
configure.in
13
configure.in
|
@ -565,6 +565,15 @@ AC_ARG_ENABLE(info-system,
|
||||||
esac],
|
esac],
|
||||||
[DISABLE_DEBUG_INFO=no]) dnl Default value
|
[DISABLE_DEBUG_INFO=no]) dnl Default value
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(debug-color,
|
||||||
|
[ --disable-debug-color disables color output of DEBUG and INFO output],
|
||||||
|
[case "${enableval}" in
|
||||||
|
yes) DISABLE_DEBUG_COLOR=no ;;
|
||||||
|
no) DISABLE_DEBUG_COLOR=yes ;;
|
||||||
|
*) AC_MSG_ERROR(bad value ${enableval} for --disable-info) ;;
|
||||||
|
esac],
|
||||||
|
[DISABLE_DEBUG_COLOR=no]) dnl Default value
|
||||||
|
|
||||||
AC_ARG_ENABLE(profiling,
|
AC_ARG_ENABLE(profiling,
|
||||||
[ --enable-profiling adds -pg to compiler commandline, for profiling],
|
[ --enable-profiling adds -pg to compiler commandline, for profiling],
|
||||||
[case "${enableval}" in
|
[case "${enableval}" in
|
||||||
|
@ -664,6 +673,10 @@ if test "x$DISABLE_DEBUG_INFO" = xyes; then
|
||||||
AC_DEFINE(GST_INFO_FORCE_DISABLE)
|
AC_DEFINE(GST_INFO_FORCE_DISABLE)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if test "x$DISABLE_DEBUG_COLOR" = xno; then
|
||||||
|
AC_DEFINE(GST_DEBUG_COLOR)
|
||||||
|
fi
|
||||||
|
|
||||||
if test "x$USE_PROFILING" = xyes; then
|
if test "x$USE_PROFILING" = xyes; then
|
||||||
CFLAGS="$CFLAGS -pg"
|
CFLAGS="$CFLAGS -pg"
|
||||||
FOMIT_FRAME_POINTER=""
|
FOMIT_FRAME_POINTER=""
|
||||||
|
|
16
gst/gst.c
16
gst/gst.c
|
@ -159,6 +159,21 @@ gst_init_check (int *argc,
|
||||||
|
|
||||||
(*argv)[i] = NULL;
|
(*argv)[i] = NULL;
|
||||||
}
|
}
|
||||||
|
else if (!strncmp ("--gst-mask=", (*argv)[i], 11)) {
|
||||||
|
guint32 val;
|
||||||
|
|
||||||
|
// handle either 0xHEX or dec
|
||||||
|
if (*((*argv)[i]+12) == 'x') {
|
||||||
|
sscanf ((*argv)[i]+13, "%08x", &val);
|
||||||
|
} else {
|
||||||
|
sscanf ((*argv)[i]+11, "%d", &val);
|
||||||
|
}
|
||||||
|
|
||||||
|
gst_debug_set_categories (val);
|
||||||
|
gst_info_set_categories (val);
|
||||||
|
|
||||||
|
(*argv)[i] = NULL;
|
||||||
|
}
|
||||||
else if (!strncmp ("--gst-plugin-spew", (*argv)[i], 17)) {
|
else if (!strncmp ("--gst-plugin-spew", (*argv)[i], 17)) {
|
||||||
_gst_plugin_spew = TRUE;
|
_gst_plugin_spew = TRUE;
|
||||||
|
|
||||||
|
@ -208,6 +223,7 @@ gst_init_check (int *argc,
|
||||||
g_print ("\nGStreamer options\n");
|
g_print ("\nGStreamer options\n");
|
||||||
g_print (" --gst-info-mask=FLAGS GST info flags to set (current %08x)\n", gst_info_get_categories());
|
g_print (" --gst-info-mask=FLAGS GST info flags to set (current %08x)\n", gst_info_get_categories());
|
||||||
g_print (" --gst-debug-mask=FLAGS GST debugging flags to set\n");
|
g_print (" --gst-debug-mask=FLAGS GST debugging flags to set\n");
|
||||||
|
g_print (" --gst-mask=FLAGS GST info *and* debug flags to set\n");
|
||||||
g_print (" --gst-plugin-spew Enable printout of errors while loading GST plugins\n");
|
g_print (" --gst-plugin-spew Enable printout of errors while loading GST plugins\n");
|
||||||
g_print (" --gst-plugin-path=PATH Add directories separated with '%s' to the plugin search path\n",
|
g_print (" --gst-plugin-path=PATH Add directories separated with '%s' to the plugin search path\n",
|
||||||
G_SEARCHPATH_SEPARATOR_S);
|
G_SEARCHPATH_SEPARATOR_S);
|
||||||
|
|
|
@ -68,6 +68,8 @@ static inline char *_gst_print_statename(int state) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: this probably should be done with an #ifdef to decide whether to safe-cast
|
||||||
|
// or to just do the non-checking cast.
|
||||||
#define GST_STATE(obj) (GST_ELEMENT(obj)->current_state)
|
#define GST_STATE(obj) (GST_ELEMENT(obj)->current_state)
|
||||||
#define GST_STATE_PENDING(obj) (GST_ELEMENT(obj)->pending_state)
|
#define GST_STATE_PENDING(obj) (GST_ELEMENT(obj)->pending_state)
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,46 @@ static gchar *_gst_info_category_strings[] = {
|
||||||
"NEGOTIATION",
|
"NEGOTIATION",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const gchar *_gst_category_colors[] = {
|
||||||
|
[GST_CAT_GST_INIT] = "00;37",
|
||||||
|
[GST_CAT_COTHREADS] = "00;32",
|
||||||
|
[GST_CAT_COTHREAD_SWITCH] = "00;32",
|
||||||
|
[GST_CAT_AUTOPLUG] = "00;34",
|
||||||
|
[GST_CAT_AUTOPLUG_ATTEMPT] = "00;34",
|
||||||
|
[GST_CAT_PARENTAGE] = "",
|
||||||
|
[GST_CAT_STATES] = "00;31",
|
||||||
|
[GST_CAT_PLANNING] = "00;35",
|
||||||
|
[GST_CAT_SCHEDULING] = "00;35",
|
||||||
|
[GST_CAT_DATAFLOW] = "00;32",
|
||||||
|
[GST_CAT_BUFFER] = "00;32",
|
||||||
|
[GST_CAT_CAPS] = "",
|
||||||
|
[GST_CAT_CLOCK] = "",
|
||||||
|
[GST_CAT_ELEMENT_PADS] = "",
|
||||||
|
[GST_CAT_ELEMENTFACTORY] = "",
|
||||||
|
[GST_CAT_PADS] = "",
|
||||||
|
[GST_CAT_PIPELINE] = "",
|
||||||
|
[GST_CAT_PLUGIN_LOADING] = "00;36",
|
||||||
|
[GST_CAT_PLUGIN_ERRORS] = "05;31",
|
||||||
|
[GST_CAT_PLUGIN_INFO] = "00;36",
|
||||||
|
[GST_CAT_PROPERTIES] = "",
|
||||||
|
[GST_CAT_THREAD] = "00;31",
|
||||||
|
[GST_CAT_TYPES] = "",
|
||||||
|
[GST_CAT_XML] = "",
|
||||||
|
[GST_CAT_NEGOTIATION] = "",
|
||||||
|
|
||||||
|
[31] = "",
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* colorization hash */
|
||||||
|
inline gint _gst_debug_stringhash_color(gchar *file) {
|
||||||
|
int filecolor;
|
||||||
|
while (file[0]) filecolor += *(char *)(file++);
|
||||||
|
filecolor = (filecolor % 6) + 31;
|
||||||
|
return filecolor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_default_info_handler:
|
* gst_default_info_handler:
|
||||||
* @category: category of the INFO message
|
* @category: category of the INFO message
|
||||||
|
@ -94,12 +134,24 @@ gst_default_info_handler (gint category, gchar *file, gchar *function,
|
||||||
if (category != GST_CAT_GST_INIT)
|
if (category != GST_CAT_GST_INIT)
|
||||||
location = g_strdup_printf("%s:%d%s:",function,line,debug_string);
|
location = g_strdup_printf("%s:%d%s:",function,line,debug_string);
|
||||||
if (element && GST_IS_ELEMENT (element))
|
if (element && GST_IS_ELEMENT (element))
|
||||||
elementname = g_strdup_printf (" [%s]", GST_OBJECT_NAME (element));
|
elementname = g_strdup_printf (" \033[04m[%s]\033[00m", GST_OBJECT_NAME (element));
|
||||||
|
|
||||||
#ifdef GST_DEBUG_ENABLED
|
#ifdef GST_DEBUG_ENABLED
|
||||||
fprintf(stderr,"INFO(%d:%d):%s%s %s\n",getpid(),cothread_getcurrent(),location,elementname,string);
|
#ifdef GST_DEBUG_COLOR
|
||||||
|
fprintf(stderr,"INFO(%d:%d):\033[" GST_DEBUG_CHAR_MODE ";%sm%s%s\033[00m %s\n",
|
||||||
|
getpid(),cothread_getcurrent(),_gst_category_colors[category],location,elementname,string);
|
||||||
|
#else
|
||||||
|
fprintf(stderr,"INFO(%d:%d):%s%s %s\n",
|
||||||
|
getpid(),cothread_getcurrent(),location,elementname,string);
|
||||||
|
#endif /* GST_DEBUG_COLOR */
|
||||||
#else
|
#else
|
||||||
fprintf(stderr,"INFO:%s%s %s\n",location,elementname,string);
|
#ifdef GST_DEBUG_COLOR
|
||||||
|
fprintf(stderr,"INFO:\033[" GST_DEBUG_CHAR_MODE ";%sm%s%s\033[00m %s\n",
|
||||||
|
location,elementname,_gst_category_colors[category],string);
|
||||||
|
#else
|
||||||
|
fprintf(stderr,"INFO:%s%s %s\n",
|
||||||
|
location,elementname,string);
|
||||||
|
#endif /* GST_DEBUG_COLOR */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (location != empty) g_free(location);
|
if (location != empty) g_free(location);
|
||||||
|
|
|
@ -34,6 +34,20 @@
|
||||||
#include "cothreads.h"
|
#include "cothreads.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* colorization stuff */
|
||||||
|
#ifdef GST_DEBUG_COLOR
|
||||||
|
#ifdef __GST_PRIVATE_H__ /* FIXME this should be some libgst.la -specific thing */
|
||||||
|
#define GST_DEBUG_CHAR_MODE "00"
|
||||||
|
#else
|
||||||
|
#define GST_DEBUG_CHAR_MODE "01"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
gint _gst_debug_stringhash_color(gchar *file);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* DEBUG system
|
* DEBUG system
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
@ -58,16 +72,30 @@ extern guint32 _gst_debug_categories;
|
||||||
/* fallback, this should probably be a 'weak' symbol or something */
|
/* fallback, this should probably be a 'weak' symbol or something */
|
||||||
G_GNUC_UNUSED static gchar *_debug_string = NULL;
|
G_GNUC_UNUSED static gchar *_debug_string = NULL;
|
||||||
|
|
||||||
#define GST_DEBUG_PREFIX(format,args...) \
|
#ifdef GST_DEBUG_COLOR
|
||||||
"DEBUG(%d:%d)" __PRETTY_FUNCTION__ ":%d" format , getpid() , cothread_getcurrent() , __LINE__ , ## args
|
#ifdef _GST_COLOR_CODE
|
||||||
|
#warning have a coded debug
|
||||||
|
#define GST_DEBUG_PREFIX(cat,format,args...) \
|
||||||
|
"DEBUG(%d:%d)\033[" _GST_COLOR_CODE "m" __PRETTY_FUNCTION__ ":%d\033[00m" format , \
|
||||||
|
getpid() , cothread_getcurrent() , __LINE__ , ## args
|
||||||
|
#else
|
||||||
|
#define GST_DEBUG_PREFIX(cat,format,args...) \
|
||||||
|
"DEBUG(%d:%d)\033[" GST_DEBUG_CHAR_MODE ";%sm" __PRETTY_FUNCTION__ ":%d\033[00m" format , \
|
||||||
|
getpid() , cothread_getcurrent() , _gst_category_colors[cat] , __LINE__ , ## args
|
||||||
|
#endif /* _GST_COLOR_CODE */
|
||||||
|
#else
|
||||||
|
#define GST_DEBUG_PREFIX(cat,format,args...) \
|
||||||
|
"DEBUG(%d:%d)" __PRETTY_FUNCTION__ ":%d" format , getpid() ,cothread_getcurrent() , __LINE__ , ## args
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef GST_DEBUG_ENABLED
|
#ifdef GST_DEBUG_ENABLED
|
||||||
#define GST_DEBUG(cat,format,args...) G_STMT_START{ \
|
#define GST_DEBUG(cat,format,args...) G_STMT_START{ \
|
||||||
if (((1<<cat) & GST_DEBUG_ENABLE_CATEGORIES) && \
|
if (((1<<cat) & GST_DEBUG_ENABLE_CATEGORIES) && \
|
||||||
((1<<cat) & _gst_debug_categories)) \
|
((1<<cat) & _gst_debug_categories)) \
|
||||||
(_debug_string != NULL) ? \
|
(_debug_string != NULL) ? \
|
||||||
fprintf(stderr,GST_DEBUG_PREFIX("%s: "format , _debug_string , ## args )) : \
|
fprintf(stderr,GST_DEBUG_PREFIX(cat,"%s: "format , _debug_string , ## args )) : \
|
||||||
fprintf(stderr,GST_DEBUG_PREFIX(": "format , ## args )); \
|
fprintf(stderr,GST_DEBUG_PREFIX(cat,": "format , ## args )); \
|
||||||
}G_STMT_END
|
}G_STMT_END
|
||||||
|
|
||||||
#define GST_DEBUG_NOPREFIX(cat,format,args...) G_STMT_START{ \
|
#define GST_DEBUG_NOPREFIX(cat,format,args...) G_STMT_START{ \
|
||||||
|
@ -79,7 +107,7 @@ G_GNUC_UNUSED static gchar *_debug_string = NULL;
|
||||||
#define GST_DEBUG_ENTER(format, args...) G_STMT_START{ \
|
#define GST_DEBUG_ENTER(format, args...) G_STMT_START{ \
|
||||||
if (((1<<31) & GST_DEBUG_ENABLE_CATEGORIES) && \
|
if (((1<<31) & GST_DEBUG_ENABLE_CATEGORIES) && \
|
||||||
((1<<31) & _gst_debug_categories)) \
|
((1<<31) & _gst_debug_categories)) \
|
||||||
fprintf(stderr,GST_DEBUG_PREFIX(format": entering\n" , ## args )); \
|
fprintf(stderr,GST_DEBUG_PREFIX(31,format": entering\n" , ## args )); \
|
||||||
}G_STMT_END
|
}G_STMT_END
|
||||||
|
|
||||||
// FIXME FIXME FIXME this leaks like crazy
|
// FIXME FIXME FIXME this leaks like crazy
|
||||||
|
@ -92,7 +120,7 @@ G_GNUC_UNUSED static gchar *_debug_string = NULL;
|
||||||
if (((1<<31) & GST_DEBUG_ENABLE_CATEGORIES) && \
|
if (((1<<31) & GST_DEBUG_ENABLE_CATEGORIES) && \
|
||||||
((1<<31) & _gst_debug_categories)) \
|
((1<<31) & _gst_debug_categories)) \
|
||||||
if (_debug_string != NULL) g_free(_debug_string),\
|
if (_debug_string != NULL) g_free(_debug_string),\
|
||||||
fprintf(stderr,GST_DEBUG_PREFIX(format": leaving\n" , ## args )); \
|
fprintf(stderr,GST_DEBUG_PREFIX(31,format": leaving\n" , ## args )); \
|
||||||
}G_STMT_END
|
}G_STMT_END
|
||||||
|
|
||||||
#define GST_DEBUG_LEAVE_STRING GST_DEBUG_LEAVE("%s",_debug_string)
|
#define GST_DEBUG_LEAVE_STRING GST_DEBUG_LEAVE("%s",_debug_string)
|
||||||
|
@ -282,6 +310,9 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
extern const gchar *_gst_category_colors[GST_CAT_MAX_CATEGORY];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
|
|
Loading…
Reference in a new issue