GStreamer 0.8 Core Reference Manual |
---|
GstInfo — Debugging and logging
#include <gst/gst.h> enum GstDebugLevel; #define GST_LEVEL_DEFAULT enum GstDebugColorFlags; struct GstDebugCategory; #define GST_STR_NULL (str) #define GST_DEBUG_PAD_NAME (pad) #define GST_FUNCTION struct GstDebugMessage; void (*GstLogFunction) (GstDebugCategory *category, GstDebugLevel level, const gchar *file, const gchar *function, gint line, GObject *object, GstDebugMessage *message, gpointer data); void gst_debug_log (GstDebugCategory *category, GstDebugLevel level, const gchar *file, const gchar *function, gint line, GObject *object, const gchar *format, ...); void gst_debug_log_valist (GstDebugCategory *category, GstDebugLevel level, const gchar *file, const gchar *function, gint line, GObject *object, const gchar *format, va_list args); const gchar* gst_debug_message_get (GstDebugMessage *message); void gst_debug_log_default (GstDebugCategory *category, GstDebugLevel level, const gchar *file, const gchar *function, gint line, GObject *object, GstDebugMessage *message, gpointer unused); G_CONST_RETURN gchar* gst_debug_level_get_name (GstDebugLevel level); void gst_debug_add_log_function (GstLogFunction func, gpointer data); guint gst_debug_remove_log_function (GstLogFunction func); guint gst_debug_remove_log_function_by_data (gpointer data); void gst_debug_set_active (gboolean active); gboolean gst_debug_is_active (void); void gst_debug_set_colored (gboolean colored); gboolean gst_debug_is_colored (void); void gst_debug_set_default_threshold (GstDebugLevel level); GstDebugLevel gst_debug_get_default_threshold (void); void gst_debug_set_threshold_for_name (const gchar *name, GstDebugLevel level); void gst_debug_unset_threshold_for_name (const gchar *name); #define GST_DEBUG_CATEGORY (cat) #define GST_DEBUG_CATEGORY_EXTERN (cat) #define GST_DEBUG_CATEGORY_STATIC (cat) #define GST_DEBUG_CATEGORY_INIT (cat,name,color,description) void gst_debug_category_free (GstDebugCategory *category); void gst_debug_category_set_threshold (GstDebugCategory *category, GstDebugLevel level); void gst_debug_category_reset_threshold (GstDebugCategory *category); GstDebugLevel gst_debug_category_get_threshold (GstDebugCategory *category); G_CONST_RETURN gchar* gst_debug_category_get_name (GstDebugCategory *category); guint gst_debug_category_get_color (GstDebugCategory *category); G_CONST_RETURN gchar* gst_debug_category_get_description (GstDebugCategory *category); GSList* gst_debug_get_all_categories (void); gchar* gst_debug_construct_term_color (guint colorinfo); #define GST_CAT_LEVEL_LOG (cat,level,object,...) #define GST_CAT_ERROR_OBJECT (cat,obj,...) #define GST_CAT_WARNING_OBJECT (cat,obj,...) #define GST_CAT_INFO_OBJECT (cat,obj,...) #define GST_CAT_DEBUG_OBJECT (cat,obj,...) #define GST_CAT_LOG_OBJECT (cat,obj,...) #define GST_CAT_ERROR (cat,...) #define GST_CAT_WARNING (cat,...) #define GST_CAT_INFO (cat,...) #define GST_CAT_DEBUG (cat,...) #define GST_CAT_LOG (cat,...) #define GST_ERROR_OBJECT (obj,...) #define GST_WARNING_OBJECT (obj,...) #define GST_INFO_OBJECT (obj,...) #define GST_DEBUG_OBJECT (obj,...) #define GST_LOG_OBJECT (obj,...) #define GST_ERROR (...) #define GST_WARNING (...) #define GST_INFO (...) #define GST_DEBUG (...) #define GST_LOG (...) #define GST_DEBUG_FUNCPTR (ptr) #define GST_DEBUG_FUNCPTR_NAME (ptr) #define gst_debug_set_log_function (func,data) #define gst_debug_reset_log_function (void) void gst_debug_print_stack_trace (void); #define GST_TIME_FORMAT #define GST_TIME_ARGS (t)
This file describes the debugging subsystem. The debugging subsystem works only after GStreamer was initilized - for example by calling gst_init.
The debugging subsystem is used to send informational strings to the debugging developer. Each messages has some properties attached to it. These properties are the debugging category, the severity (called "level" here) and an obtional GObject it belongs to. Each of these messages is sent to all registered debugging handlers, which then handle the messages. GStreamer attaches a default handler on startup, which outputs requested messages to stderr.
Messages are output by using shortcut macros like GST_DEBUG, GST_CAT_ERROR_OBJECT or similar. These all expand to calling gst_debug_log with the right parameters. The only thing a developer will probably want to do is define his own categories. This is easily done with 3 lines. At the top of your code, declare the variables and set the default category.
GST_DEBUG_CATEGORY (my_category); /* define category */ #define GST_CAT_DEFAULT my_category /* set as default */
After that you only need to initialize the category.
GST_DEBUG_CATEGORY_INIT (my_category, "my category", 0, "This is my very own");
Initialization must be done before the category is used first. Plugins do this in their plugin_init function, libraries and applications should do that during their initialization.
The whole debugging subsystem can be disabled at build time with passing the --disable-gst-debug switch to configure. If this is done, every function, macro and even structs described in this file evaluate to default values or nothing at all. So don't take addresses of these functions or use other tricks. If you must do that for some reason, there is still an option. If the debugging subsystem was compiled out, GST_DISABLE_GST_DEBUG is defined in <gst/gst.h>, so you can check that before doing your trick. Disabling the debugging subsystem will give you a slight (read: unnoticable) speed increase and will reduce the size of your compiled code. The GStreamer library itself becomes around 10% smaller.
Please note that there are naming conventions for the names of debugging categories. These are explained at GST_DEBUG_CATEGORY_INIT().
typedef enum { GST_LEVEL_NONE = 0, GST_LEVEL_ERROR, GST_LEVEL_WARNING, GST_LEVEL_INFO, GST_LEVEL_DEBUG, GST_LEVEL_LOG, /* add more */ GST_LEVEL_COUNT } GstDebugLevel;
The level defines the importance of a debugging message. The more important a message is, the greater the probability that the debugging system outputs it.
GST_LEVEL_NONE | No debugging level specified or desired. Used to deactivate debugging output. |
GST_LEVEL_ERROR | Error messages are to be used only when an error occured that stops the application from keeping working correctly. An examples is gst_element_error, which outputs a message with this priority. It does not mean that the application is terminating as with g_errror. |
GST_LEVEL_WARNING | Warning messages are to inform about abnormal behaviour that could lead to problems or weird behaviour later on. An example of this would be clocking issues ("your computer is pretty slow") or broken input data ("Can't synchronize to stream.") |
GST_LEVEL_INFO | Informational messages should be used to keep the developer updated about what is happening. Examples where this should be used are when a typefind function has successfully determined the type of the stream or when an mp3 plugin detects the format to be used. ("This file has mono sound.") |
GST_LEVEL_DEBUG | Debugging messages should be used when something common happens that is not the expected default behavior. An example would be notifications about state changes or receiving/sending of events. |
GST_LEVEL_LOG | Log messages are messages that are very common but might be useful to know. As a rule of thumb a pipeline that is iterating as expected should never output anzthing else but LOG messages. Examples for this are referencing/dereferencing of objects or cothread switches. |
GST_LEVEL_COUNT | The number of defined debugging levels. |
#define GST_LEVEL_DEFAULT GST_LEVEL_NONE
Defines the default debugging level to be used with GStreamer. It is normally set to GST_LEVEL_ERROR so only errors are printed. Developer builds may chose to override that though. You can use this as an argument to gst_debug_set_default_threshold() to reset the debugging output to default behaviour.
typedef enum { /* colors */ GST_DEBUG_FG_BLACK = 0x0000, GST_DEBUG_FG_RED = 0x0001, GST_DEBUG_FG_GREEN = 0x0002, GST_DEBUG_FG_YELLOW = 0x0003, GST_DEBUG_FG_BLUE = 0x0004, GST_DEBUG_FG_MAGENTA = 0x0005, GST_DEBUG_FG_CYAN = 0x0006, GST_DEBUG_FG_WHITE = 0x0007, /* background colors */ GST_DEBUG_BG_BLACK = 0x0000, GST_DEBUG_BG_RED = 0x0010, GST_DEBUG_BG_GREEN = 0x0020, GST_DEBUG_BG_YELLOW = 0x0030, GST_DEBUG_BG_BLUE = 0x0040, GST_DEBUG_BG_MAGENTA = 0x0050, GST_DEBUG_BG_CYAN = 0x0060, GST_DEBUG_BG_WHITE = 0x0070, /* other formats */ GST_DEBUG_BOLD = 0x0100, GST_DEBUG_UNDERLINE = 0x0200 } GstDebugColorFlags;
These are some terminal-oriented flags you can use when creating your debugging categories to make them stand out in debugging output.
GST_DEBUG_FG_BLACK | Use black as foreground color. |
GST_DEBUG_FG_RED | Use red as foreground color. |
GST_DEBUG_FG_GREEN | Use green as foreground color. |
GST_DEBUG_FG_YELLOW | Use yellow as foreground color. |
GST_DEBUG_FG_BLUE | Use blue as foreground color. |
GST_DEBUG_FG_MAGENTA | Use magenta as foreground color. |
GST_DEBUG_FG_CYAN | Use cyan as foreground color. |
GST_DEBUG_FG_WHITE | Use white as foreground color. |
GST_DEBUG_BG_BLACK | Use black as background color. |
GST_DEBUG_BG_RED | Use red as background color. |
GST_DEBUG_BG_GREEN | Use green as background color. |
GST_DEBUG_BG_YELLOW | Use yellow as background color. |
GST_DEBUG_BG_BLUE | Use blue as background color. |
GST_DEBUG_BG_MAGENTA | Use magenta as background color. |
GST_DEBUG_BG_CYAN | Use cyan as background color. |
GST_DEBUG_BG_WHITE | Use white as background color. |
GST_DEBUG_BOLD | Make the output bold. |
GST_DEBUG_UNDERLINE | Underline the output. |
struct GstDebugCategory { };
This is the struct that describes the categories. Once initialized with GST_DEBUG_CATEGORY_INIT, its values can't be changed anymore.
#define GST_STR_NULL(str) ((str) ? (str) : "(NULL)")
Macro to use when a string must not be NULL, but may be NULL. If the string is NULL, "(NULL)" is printed instead. In GStreamer printf string arguments may not be NULL, because on some platforms (ie Solaris) the libc crashes in that case. This includes debugging strings.
str : | The string to check. |
Returns : | A string that is guaranteed to be not NULL. |
#define GST_DEBUG_PAD_NAME(pad)
Evaluates to 2 strings, that describe the pad. Often used in debugging statements.
pad : | The pad to debug. |
#define GST_FUNCTION
This macro should evaluate to the name of the current function and be should be defined when configuring your project, as it is compiler dependant. If it is not defined, some default value is used. It is used to provide debugging output with the function name of the message.
void (*GstLogFunction) (GstDebugCategory *category, GstDebugLevel level, const gchar *file, const gchar *function, gint line, GObject *object, GstDebugMessage *message, gpointer data);
category : | |
level : | |
file : | |
function : | |
line : | |
object : | |
message : | |
data : |
void gst_debug_log (GstDebugCategory *category, GstDebugLevel level, const gchar *file, const gchar *function, gint line, GObject *object, const gchar *format, ...);
Logs the given message using the currently registered debugging handlers.
category : | category to log |
level : | level of the message is in |
file : | the file that emitted the message, usually the __FILE__ identifier |
function : | the function that emitted the message |
line : | the line from that the message was emitted, usually __LINE__ |
object : | the object this message relates to or NULL if none |
format : | a printf style format string |
... : | optional arguments for the format |
void gst_debug_log_valist (GstDebugCategory *category, GstDebugLevel level, const gchar *file, const gchar *function, gint line, GObject *object, const gchar *format, va_list args);
Logs the given message using the currently registered debugging handlers.
category : | category to log |
level : | level of the message is in |
file : | the file that emitted the message, usually the __FILE__ identifier |
function : | the function that emitted the message |
line : | the line from that the message was emitted, usually __LINE__ |
object : | the object this message relates to or NULL if none |
format : | a printf style format string |
args : | optional arguments for the format |
const gchar* gst_debug_message_get (GstDebugMessage *message);
Gets the string representation of a GstDebugMessage. This function is used in debug handlers to extract the message.
message : | a debug message |
Returns : | the string representation of a GstDebugMessage. |
void gst_debug_log_default (GstDebugCategory *category, GstDebugLevel level, const gchar *file, const gchar *function, gint line, GObject *object, GstDebugMessage *message, gpointer unused);
The default logging handler used by GStreamer. Logging functions get called whenever a macro like GST_DEBUG or similar is used. This function outputs the message and additional info using the glib error handler. You can add other handlers by using gst_debug_add_log_function. And you can remove this handler by calling gst_debug_remove_log_function (gst_debug_log_default);
category : | category to log |
level : | level of the message |
file : | the file that emitted the message, usually the __FILE__ identifier |
function : | the function that emitted the message |
line : | the line from that the message was emitted, usually __LINE__ |
object : | the object this message relates to or NULL if none |
message : | the actual message |
unused : | an unused variable, reserved for some user_data. |
G_CONST_RETURN gchar* gst_debug_level_get_name (GstDebugLevel level);
Get the string trepresentation of a debugging level
level : | the level to get the name for |
Returns : | the name |
void gst_debug_add_log_function (GstLogFunction func, gpointer data);
Adds the logging function to the list of logging functions. Be sure to use G_GNUC_NO_INSTRUMENT on that function, it is needed.
func : | the function to use |
data : | user data |
guint gst_debug_remove_log_function (GstLogFunction func);
Removes all registrered instances of the given logging functions.
func : | the log function to remove |
Returns : | How many instances of the function were removed |
guint gst_debug_remove_log_function_by_data (gpointer data);
Removes all registrered instances of log functions with the given user data.
data : | user data of the log function to remove |
Returns : | How many instances of the function were removed |
void gst_debug_set_active (gboolean active);
If activated, debugging messages are sent to the debugging handlers. It makes sense to deactivate it for speed issues.
This function is not threadsafe. It makes sense to only call it during initialization.
active : | Whether to use debugging output or not |
gboolean gst_debug_is_active (void);
Checks if debugging output is activated.
Returns : | TRUE, if debugging is activated |
void gst_debug_set_colored (gboolean colored);
Sets or unsets the use of coloured debugging output.
colored : | Whether to use colored output or not |
gboolean gst_debug_is_colored (void);
Checks if the debugging output should be colored.
Returns : | TRUE, if the debug output should be colored. |
void gst_debug_set_default_threshold (GstDebugLevel level);
Sets the default threshold to the given level and updates all categories to use this threshold.
level : | level to set |
GstDebugLevel gst_debug_get_default_threshold (void);
Returns the default threshold that is used for new categories.
Returns : | the default threshold level |
void gst_debug_set_threshold_for_name (const gchar *name, GstDebugLevel level);
Sets all categories which match the given glob style pattern to the given level.
name : | name of the categories to set |
level : | level to set them to |
void gst_debug_unset_threshold_for_name (const gchar *name);
Resets all categories with the given name back to the default level.
name : | name of the categories to set |
#define GST_DEBUG_CATEGORY(cat)
Defines a GstDebugCategory variable. This macro expands to nothing if debugging is disabled.
cat : | the category |
#define GST_DEBUG_CATEGORY_EXTERN(cat)
Declares a GstDebugCategory variable as extern. Use in header files. This macro expands to nothing if debugging is disabled.
cat : | the category |
#define GST_DEBUG_CATEGORY_STATIC(cat)
Defines a static GstDebugCategory variable. This macro expands to nothing if debugging is disabled.
cat : | the category |
#define GST_DEBUG_CATEGORY_INIT(cat,name,color,description)
Initializes a new GstDebugCategory with the given properties and set to the default threshold.
This macro expands to nothing if debugging is disabled.
When naming your category, please follow the following conventions to ensure that the pattern matching for categories works as expected. It is not earth-shattering if you don't follow these conventions, but it would be nice for everyone.
If you define a category for a plugin or a feature of it, name the category like the feature. So if you wanted to write a "filesrc" element, you would name the category "filesrc". Use lowercase letters only. If you define more than one category for the same element, append an underscore and an identifier to your categories, like this: "filesrc_cache"
If you create a library or an application using debugging categories, use a common prefix followed by an underscore for all your categories. GStreamer uses the GST prefix so GStreamer categories look like "GST_STATES". Be sure to include uppercase letters.
cat : | the category to initialize. |
name : | the name of the category. |
color : | the colors to use for a color representation or 0 for no color. |
description : | optional description of the category. |
void gst_debug_category_free (GstDebugCategory *category);
Removes and frees the category and all associated resources.
category : | GstDebugCategory to free. |
void gst_debug_category_set_threshold (GstDebugCategory *category, GstDebugLevel level);
Sets the threshold of the category to the given level. Debug information will only be output if the threshold is lower or equal to the level of the debugging message.
Do not use this function in production code, because other functions may change the threshold of categories as side effect. It is however a nice function to use when debugging (even from gdb).
category : | a GstDebugCategory to set threshold of. |
level : | the GstDebugLevel threshold to set. |
void gst_debug_category_reset_threshold (GstDebugCategory *category);
Resets the threshold of the category to the default level. Debug information will only be output if the threshold is lower or equal to the level of the debugging message. Use this function to set the threshold back to where it was after using gst_debug_category_set_threshold().
category : | a GstDebugCategory to reset threshold of. |
GstDebugLevel gst_debug_category_get_threshold (GstDebugCategory *category);
Returns the threshold of a GstCategory.
category : | a GstDebugCategory to get threshold of. |
Returns : | the GstDebugLevel that is used as threshold. |
G_CONST_RETURN gchar* gst_debug_category_get_name (GstDebugCategory *category);
Returns the name of a debug category.
category : | a GstDebugCategory to get name of. |
Returns : | the name of the category. |
guint gst_debug_category_get_color (GstDebugCategory *category);
Returns the color of a debug category used when printing output in this category.
category : | a GstDebugCategory to get the color of. |
Returns : | the color of the category. |
G_CONST_RETURN gchar* gst_debug_category_get_description (GstDebugCategory *category);
Returns the description of a debug category.
category : | a GstDebugCategory to get the description of. |
Returns : | the description of the category. |
GSList* gst_debug_get_all_categories (void);
Returns a snapshot of a all categories that are currently in use . This list may change anytime. The caller has to free the list after use. This function is not threadsafe, so only use it while only the main thread is running.
Returns : | the list of categories |
gchar* gst_debug_construct_term_color (guint colorinfo);
Constructs a string that can be used for getting the desired color in color terminals. You need to free the string after use.
colorinfo : | the color info |
Returns : | a string containing the color definition |
#define GST_CAT_LEVEL_LOG(cat,level,object,...)
GST_CAT_LEVEL_LOG: Outputs a debugging message. This is the most general macro for outputting debugging messages. You will probably want to use one of the ones described below.
cat : | category to use |
level : | the severity of the message |
object : | the GObject the message belongs to or NULL if none |
... : | A printf-style message to output |
#define GST_CAT_ERROR_OBJECT(cat,obj,...)
Output an error message belonging to the given object in the given category.
cat : | category to use |
obj : | the GObject the message belongs to |
... : | printf-style message to output |
#define GST_CAT_WARNING_OBJECT(cat,obj,...)
Output a warning message belonging to the given object in the given category.
cat : | category to use |
obj : | the GObject the message belongs to |
... : | printf-style message to output |
#define GST_CAT_INFO_OBJECT(cat,obj,...)
Output an informational message belonging to the given object in the given category.
cat : | category to use |
obj : | the GObject the message belongs to |
... : | printf-style message to output |
#define GST_CAT_DEBUG_OBJECT(cat,obj,...)
Output an debugging message belonging to the given object in the given category.
cat : | category to use |
obj : | the GObject the message belongs to |
... : | printf-style message to output |
#define GST_CAT_LOG_OBJECT(cat,obj,...)
Output an logging message belonging to the given object in the given category.
cat : | category to use |
obj : | the GObject the message belongs to |
... : | printf-style message to output |
#define GST_CAT_ERROR(cat,...)
Output an error message in the given category.
cat : | category to use |
... : | printf-style message to output |
#define GST_CAT_WARNING(cat,...)
Output a warning message in the given category.
cat : | category to use |
... : | printf-style message to output |
#define GST_CAT_INFO(cat,...)
Output an informational message in the given category.
cat : | category to use |
... : | printf-style message to output |
#define GST_CAT_DEBUG(cat,...)
Output a debuggign message in the given category.
cat : | category to use |
... : | printf-style message to output |
#define GST_CAT_LOG(cat,...)
Output a logging message in the given category.
cat : | category to use |
... : | printf-style message to output |
#define GST_ERROR_OBJECT(obj,...)
Output an error message belonging to the given object in the default category.
obj : | the GObject the message belongs to |
... : | printf-style message to output |
#define GST_WARNING_OBJECT(obj,...)
Output a warning message belonging to the given object in the default category.
obj : | the GObject the message belongs to |
... : | printf-style message to output |
#define GST_INFO_OBJECT(obj,...)
Output an informational message belonging to the given object in the default category.
obj : | the GObject the message belongs to |
... : | printf-style message to output |
#define GST_DEBUG_OBJECT(obj,...)
Output a debugging message belonging to the given object in the default category.
obj : | the GObject the message belongs to |
... : | printf-style message to output |
#define GST_LOG_OBJECT(obj,...)
Output a logging message belonging to the given object in the default category.
obj : | the GObject the message belongs to |
... : | printf-style message to output |
#define GST_ERROR(...)
Output an error message in the default category.
... : | printf-style message to output |
#define GST_WARNING(...)
Output a warning message in the default category.
... : | printf-style message to output |
#define GST_INFO(...)
Output an informational message in the default category.
... : | printf-style message to output |
#define GST_DEBUG(...)
Output a debugging message in the default category.
... : | printf-style message to output |
#define GST_LOG(...)
Output a logging message in the default category.
... : | printf-style message to output |
#define GST_DEBUG_FUNCPTR(ptr)
Register a pointer to a function with its name, so it can later be used by GST_DEBUG_FUNCPTR_NAME().
ptr : | The function to register Returns: The ptr to the function. |
#define GST_DEBUG_FUNCPTR_NAME(ptr)
Retrieves the name of the function, if it was previously registered with GST_DEBUG_FUNCPTR(). If not, it returns a description of the pointer.
Make sure you free the string after use.
ptr : | pointer to the function Returns: The name of the function |
configuration, initialization for command line parameters and environment variables that affect the debugging output.
<< GstIndexFactory | GstObject >> |