Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2006-08-11 13:21:11 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2006-08-11 13:21:11 (GMT)
commit884eef4bd52a33d13a1c509bf004842fa7b58652 (patch)
tree7e22f60ebdf97599ba247a79df3f097edd0e8f64 /sugar
parent628271959c97c49b64ed16203a5d8a2d0202ede7 (diff)
Show all activities output in the console, just
activate the tab for the current activity.
Diffstat (limited to 'sugar')
-rw-r--r--sugar/logger.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/sugar/logger.py b/sugar/logger.py
index 54cb15b..df5aebd 100644
--- a/sugar/logger.py
+++ b/sugar/logger.py
@@ -1,8 +1,14 @@
+import sys
import logging
+import traceback
+from cStringIO import StringIO
import dbus
import gobject
+__sugar_shell = None
+__console_id = None
+
class Handler(logging.Handler):
def __init__(self, shell, console_id):
logging.Handler.__init__(self)
@@ -13,8 +19,8 @@ class Handler(logging.Handler):
def _log(self):
for message in self._messages:
- # FIXME use a single dbus call
self._shell.log(self._console_id, message)
+ self._messages = []
return False
def emit(self, record):
@@ -22,6 +28,12 @@ class Handler(logging.Handler):
if len(self._messages) == 1:
gobject.idle_add(self._log)
+def __exception_handler(typ, exc, tb):
+ trace = StringIO()
+ traceback.print_exception(typ, exc, tb, None, trace)
+
+ __sugar_shell.log(__console_id, trace.getvalue())
+
def start(console_id, shell = None):
root_logger = logging.getLogger('')
root_logger.setLevel(logging.DEBUG)
@@ -32,3 +44,10 @@ def start(console_id, shell = None):
shell = dbus.Interface(proxy_obj, 'com.redhat.Sugar.Shell')
root_logger.addHandler(Handler(shell, console_id))
+
+ global __sugar_shell
+ global __console_id
+
+ __sugar_shell = shell
+ __console_id = console_id
+ sys.excepthook = __exception_handler