sugar-toolkit-gtk3/sugar/LogWriter.py
Marco Pesenti Gritti d6ec6db880 Make the console contextual to the activity and use the
window manager to activate it.
2006-07-20 12:13:47 +02:00

35 lines
759 B
Python

import sys
import logging
import dbus
import sugar.env
class LogWriter:
def __init__(self, application, use_console = True):
self._application = application
self._use_console = use_console
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')
def start(self):
if 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')
def write(self, s):
self._logger.log(self._application, s, ignore_reply=True)
def emit(self, record):
pass
def flush(self):
pass