python excepthook / logging

Issue #115 resolved
Joris created an issue

Whenever an exception in a python module occurs, the error is only sent to stderr.

It would be very useful if exceptions also went to logman.

I do this with a simple python module: {{{ #!python

import asss import sys

lm = asss.get_interface(asss.I_LOGMAN)

def excepthook(type, value, tb): import traceback tblines = traceback.format_exception(type, value, tb)

for line in tblines:
    lm.Log(asss.L_ERROR, "<pymod> "+line)
sys.__excepthook__(type, value, traceback)

sys.excepthook = excepthook }}}

Maybe it would be worthwhile to add this to pymod?

Or even go a step further and integrate with logging ( http://docs.python.org/library/logging.html )

Comments (2)

  1. Log in to comment