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

35 lines
759 B
Python
Raw Normal View History

2006-05-23 16:02:13 -04:00
import sys
import logging
2006-05-16 19:23:42 -04:00
import dbus
import sugar.env
2006-05-16 19:23:42 -04:00
class LogWriter:
def __init__(self, application, use_console = True):
2006-05-16 19:23:42 -04:00
self._application = application
self._use_console = use_console
2006-05-16 19:23:42 -04:00
bus = dbus.SessionBus()
proxy_obj = bus.get_object('com.redhat.Sugar.Shell', '/com/redhat/Sugar/Shell')
self._logger = dbus.Interface(proxy_obj, 'com.redhat.Sugar.Shell')
2006-05-23 16:02:13 -04:00
def start(self):
2006-06-19 23:04:53 -04:00
if self._use_console:
2006-05-23 16:02:13 -04:00
sys.stdout = self
sys.stderr = self
level = sugar.env.get_logging_level()
if level == 'debug':
logging.basicConfig(level=logging.DEBUG,
format='%(levelname)s %(message)s')
2006-05-16 19:23:42 -04:00
def write(self, s):
self._logger.log(self._application, s, ignore_reply=True)
def emit(self, record):
pass
def flush(self):
pass