Files
sugar-toolkit-gtk3/sugar/session/LogWriter.py
T

24 lines
560 B
Python
Raw Normal View History

2006-05-23 16:02:13 -04:00
import os
import sys
2006-05-16 19:23:42 -04:00
import dbus
2006-06-13 15:18:04 -04:00
import gobject
2006-05-16 19:23:42 -04:00
class LogWriter:
def __init__(self, application):
self._application = application
bus = dbus.SessionBus()
proxy_obj = bus.get_object('com.redhat.Sugar.Logger', '/com/redhat/Sugar/Logger')
self._logger = dbus.Interface(proxy_obj, 'com.redhat.Sugar.Logger')
2006-05-23 16:02:13 -04:00
def start(self):
if os.environ.has_key('SUGAR_USE_CONSOLE'):
sys.stdout = self
sys.stderr = self
2006-05-16 19:23:42 -04:00
def write(self, s):
2006-06-13 15:18:04 -04:00
gobject.idle_add(self._write, s)
def _write(self, s):
self._logger.log(self._application, s)
return False