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 677917 - g-i: annotate/expose logging system for bindings
g-i: annotate/expose logging system for bindings
Status: RESOLVED WONTFIX
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal enhancement
: NONE
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-06-12 04:54 UTC by Ángel Guzmán Maeso (shakaran)
Modified: 2015-08-14 11:23 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Ángel Guzmán Maeso (shakaran) 2012-06-12 04:54:12 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):
  • File "/home/shakaran/gst_debug.py", line 31 in <module>
    unused = 0,
  • File "/usr/lib/python2.7/dist-packages/gi/types.py", line 47 in function
    return info.invoke(*args, **kwargs)
TypeError: Must be number, not str

Comment 1 Tim-Philipp Müller 2012-10-29 00:06:06 UTC
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.
Comment 2 Edward Hervey 2013-08-14 08:10:22 UTC
Angel, please confirm the above works for you
Comment 3 Ángel Guzmán Maeso (shakaran) 2013-08-14 09:32:14 UTC
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.
Comment 4 Tim-Philipp Müller 2015-08-14 11:23:23 UTC
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.