Setup python logging and use it in the PresenceService

This commit is contained in:
Marco Pesenti Gritti
2006-06-17 19:54:12 -04:00
parent 361eeff0c5
commit 53f00b05b1
5 changed files with 49 additions and 17 deletions
+20 -3
View File
@@ -1,18 +1,35 @@
import os
import sys
import logging
import dbus
import sugar.env
class LogWriter:
def __init__(self, application):
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.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'):
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')
def write(self, s):
self._logger.log(self._application, s, ignore_reply=True)
def emit(self, record):
pass
def flush(self):
pass