I want to set the log level in my python glib project. Therefore I am looking for the g_log_set_handler()
equivalent when using GLib from python via gi.repository
.
But the expected GLib.log_set_handler
function seems to be missing. Here is a sample output of my python shell:
~$ python
Python 2.7.3 (default, Apr 10 2013, 06:20:15)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from gi.repository import GLib
>>> GLib.log_set_fatal_mask
<function log_set_fatal_mask at 0x2a7b668>
>>> GLib.log_set_handler
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/gi/module.py", line 316, in __getattr__
attr = super(DynamicGLibModule, self).__getattr__(name)
File "/usr/lib/python2.7/dist-packages/gi/module.py", line 243, in __getattr__
return getattr(self._introspection_module, name)
File "/usr/lib/python2.7/dist-packages/gi/module.py", line 105, in __getattr__
self.__name__, name))
AttributeError: 'gi.repository.GLib' object has no attribute 'log_set_handler'
>>>
As one can see, GLib from the introspection repository is found and the log_set_fatal_mask function exists (which is the equivalent of the g_log_set_fatal_mask
). But log_set_handler
is not found.
Why is that and how could I correctly set my loglevel from within python?
I found out this is currently not possible and a known bug within either gobject-introspection
or glib
, since g_log_set_handler
is not bindable.