2006-05-23 22:02:13 +02:00
|
|
|
import os
|
|
|
|
import sys
|
2006-05-17 01:23:42 +02:00
|
|
|
import dbus
|
|
|
|
|
|
|
|
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 22:02:13 +02:00
|
|
|
def start(self):
|
|
|
|
if os.environ.has_key('SUGAR_USE_CONSOLE'):
|
|
|
|
sys.stdout = self
|
|
|
|
sys.stderr = self
|
|
|
|
|
2006-05-17 01:23:42 +02:00
|
|
|
def write(self, s):
|
2006-06-01 00:01:24 +02:00
|
|
|
self._logger.log(self._application, s)
|