GNOME Bugzilla – Bug 677917
g-i: annotate/expose logging system for bindings
Last modified: 2015-08-14 11:23:23 UTC
Using the object Gst.debug_log_default() function causes a TypeError exception on python. I am using Ubuntu 12.10 with Gstreamer 0.11.91-2. This is the exaple code: #!/usr/bin/env python # -*- coding: utf-8; tab-width: 4; mode: python -*- # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet import sys import gi try: gi.require_version('Gst', '1.0') from gi.repository import Gst except ValueError: print 'Could not find required Gstreamer 1.0 library.' sys.exit(1) # Setup GStreamer Gst.init(None) Gst.init_check(None) print Gst.version_string(), Gst.version() Gst.debug_set_active(True) # If activated, debugging messages are sent to the debugging handlers. Gst.debug_log_default( category = Gst.DebugCategory(), level = Gst.DebugLevel.ERROR, file = 'gst-error.log', function = 'myfunction', line = '100', object = 'myobject', message = 'this is a error', unused = 0, ) The unused param according to Gst-1.0.gif file is a gpointer: <parameter name="unused" transfer-ownership="none"> <doc xml:whitespace="preserve">an unused variable, reserved for some user_data.</doc> <type name="gpointer" c:type="gpointer"/> </parameter> Running the example shows this traceback GStreamer 1.0.0 (1L, 0L, 0L, 0L) Traceback (most recent call last):
+ Trace 230346
unused = 0,
return info.invoke(*args, **kwargs)
FWIW, there are some overrides in the gst-python module now: commit 93ab67c78b4b13918e2431617c88ea42c36b2920 Author: Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> Date: Thu Sep 27 14:41:29 2012 +0200 overrides: provide for gst-python style debug logging Also provide a default debug category for the binding glue code. (In reply to comment #0) > > Using the object Gst.debug_log_default() function causes a TypeError > exception on python. > > Gst.debug_log_default( > category = Gst.DebugCategory(), > level = Gst.DebugLevel.ERROR, > file = 'gst-error.log', > function = 'myfunction', > line = '100', You are passing a string here, it should be an integer (though maybe python converts it automagically, I don't know. > object = 'myobject', You are passing a string here, it should be an object (perhaps try None instead?) > message = 'this is a error', This would be a GstDebugMessage structure, which I don't know if you can just create it from python. Definitely not just a string. (The point of this structure is to avoid constructing the string if it's not going to be used because of some filter criterion.) > unused = 0, > ) It's a pointer, so None might work better ? If the overrides aren't enough, we'd probably have to add a new function that works better with bindings.
Angel, please confirm the above works for you
Sorry for delay reply. I am using 1.0.8 in Ubuntu Saucy right now. It seems that we need a constructor for DebugMessage at least: msg = Gst.DebugMessage() TypeError: cannot allocate disguised struct Gst.DebugMessage; consider adding a constructor to the library or to the overrides Changing unused to None, it still produces: TypeError: Must be number, not str If I write a dummy object to pass like: class DummyO(object): pass a = DummyO() Also produces the same error for unused or object param.
No activity, let's close this. Problem is that if we did provide some kind of generic gst_log() function or so, you wouldn't get nice things like the name of the file (in the language binding's language) printed in the log, and things like that. So probably best to leave this to overrides. If someone ever feels strongly enough about this to propose a patch, we'll reconsider.