After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 571380 - Allow user to specify filename and line number for gst_debug_log for compatibility with Python logging module
Allow user to specify filename and line number for gst_debug_log for compatib...
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-python
git master
Other All
: Normal enhancement
: 0.10.15
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2009-02-12 01:50 UTC by Laszlo Pandy
Modified: 2009-04-11 15:00 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
Patch to implement gst.debug_log() (1.24 KB, patch)
2009-02-12 01:58 UTC, Laszlo Pandy
committed Details | Review
Test case for gst.debug_log() using Python's logging module. (608 bytes, text/x-python)
2009-02-12 01:59 UTC, Laszlo Pandy
  Details

Description Laszlo Pandy 2009-02-12 01:50:55 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.
Comment 1 Laszlo Pandy 2009-02-12 01:58:19 UTC
Created attachment 128510 [details] [review]
Patch to implement gst.debug_log()
Comment 2 Laszlo Pandy 2009-02-12 01:59:30 UTC
Created attachment 128511 [details]
Test case for gst.debug_log() using Python's logging module.
Comment 3 Edward Hervey 2009-04-11 15:00:22 UTC
commit 4d8b4c8dd38f727fb0229fcacc9c883ad6a4f022
Author: Laszlo Pandy <laszlok2@gmail.com>
Date:   Sat Apr 11 16:58:25 2009 +0200

    debug: Implement gst.debug_log. Fixes #571380