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

36 lines
816 B
Python
Raw Normal View History

import os
import sys
import logging
2006-05-17 01:23:42 +02:00
import dbus
import sugar.env
2006-05-17 01:23:42 +02:00
class LogWriter:
def __init__(self, application, use_console = True):
2006-05-17 01:23:42 +02:00
self._application = application
self._use_console = use_console
2006-05-17 01:23:42 +02:00
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')
def start(self):
if os.environ.has_key('SUGAR_USE_CONSOLE') and self._use_console:
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-17 01:23:42 +02:00
def write(self, s):
self._logger.log(self._application, s, ignore_reply=True)
def emit(self, record):
pass
def flush(self):
pass