GNOME Bugzilla – Bug 571380
Allow user to specify filename and line number for gst_debug_log for compatibility with Python logging module
Last modified: 2009-04-11 15:00:22 UTC
Here is a patch to create a python method gst.debug_log(), which has parameters very similar to the C function gst_debug_log(). It differs from gst.debug() in that it lets you specify the level, filename, function, and line number. It solves the problem that if the Python code uses a separate logging system (such as Python's logging module), we can make the logging system redirect output to Gstreamer but the filename, function and line number that is printed will always be those from the logging system, and not from where the message originated. For example: def mylog(message): print message gst.debug(message) def foo(): mylog("enter foo") # do something mylog("leave foo") With the above code, you will see this in the gstreamer log: 0:00:00.167498608 1024 0x9c931d8 DEBUG python log.py:3:mylog: enter foo 0:00:00.167498700 1024 0x9c931d8 DEBUG python log.py:3:mylog: leave foo All debug messages will have the same filename, function and line number. I have attached a patch from current git, as well as a log.py file which demonstrates a use case of the patch with Python's logging module.
Created attachment 128510 [details] [review] Patch to implement gst.debug_log()
Created attachment 128511 [details] Test case for gst.debug_log() using Python's logging module.
commit 4d8b4c8dd38f727fb0229fcacc9c883ad6a4f022 Author: Laszlo Pandy <laszlok2@gmail.com> Date: Sat Apr 11 16:58:25 2009 +0200 debug: Implement gst.debug_log. Fixes #571380