最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c++ - How to redirect gstreamer debug information to a logging library - Stack Overflow

programmeradmin0浏览0评论

I have gstreamer pipelines running in my C++ application. To check problems relative to those, I enable printing debug information by setting the variable GST_DEBUG as explained on this page : .html?gi-language=c. However, this prints directly on cout and I use a logging library (log4cplus) in my application. As gstreamer debug information is divided in categories very similar to the ones in log4cplus (error, warn, debug, etc.), I expected it would be possible to redirect those messages in my logger but I cannot find any information on how to do it.

I used the Qt framework before, and it has a function 'qInstallMessageHandler' which enables redirecting qt logs to a custom logger. Does gstreamer have anything like that?

I have gstreamer pipelines running in my C++ application. To check problems relative to those, I enable printing debug information by setting the variable GST_DEBUG as explained on this page : https://gstreamer.freedesktop./documentation/tutorials/basic/debugging-tools.html?gi-language=c. However, this prints directly on cout and I use a logging library (log4cplus) in my application. As gstreamer debug information is divided in categories very similar to the ones in log4cplus (error, warn, debug, etc.), I expected it would be possible to redirect those messages in my logger but I cannot find any information on how to do it.

I used the Qt framework before, and it has a function 'qInstallMessageHandler' which enables redirecting qt logs to a custom logger. Does gstreamer have anything like that?

Share Improve this question asked Nov 19, 2024 at 8:45 NyacreepsNyacreeps 233 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I have no experience with this but it looks like you can register a C function that will get called by the Gstreamer framework when it logs.

static void gst_log_handler(GstDebugCategory *category,
    GstDebugLevel level, const gchar *file, const gchar *function,
    gint line, GObject *object, GstDebugMessage *message, gpointer user_data) {
    // Convert into log4cplus::spi::InternalLoggingEvent and log it.
}

// Somewhere else then register it:
gst_debug_add_log_function(debug_category, gst_log_handler, nullptr);
发布评论

评论列表(0)

  1. 暂无评论