Message101605
Sean Reifschneider proposed [1] adding the ability to log an exception using the syslog module.
My proposed implementation is along the lines of:
def logexceptions(chain=True):
import sys
import traceback
import syslog
# Should we chain to the existing sys.excepthook?
current_hook = sys.excepthook if chain else None
def syslog_exception(etype, evalue, etb):
if current_hook:
current_hook(etype, evalue, etb)
# The result of traceback.format_exception might contain
# embedded newlines, so we have the nested loops.
for line in traceback.format_exception(etype, evalue, etb):
for line in line.rstrip().split('\n'):
syslog.syslog(line)
sys.excepthook = syslog_exception
Although it would need to be written in C to work in the existing syslog module, and of course it would call syslog.syslog directly.
[1] http://mail.python.org/pipermail/python-ideas/2010-March/006927.html |
|
Date |
User |
Action |
Args |
2010-03-23 22:12:13 | eric.smith | set | recipients:
+ eric.smith, jafo |
2010-03-23 22:12:13 | eric.smith | set | messageid: <1269382333.64.0.598164519082.issue8214@psf.upfronthosting.co.za> |
2010-03-23 22:12:11 | eric.smith | link | issue8214 messages |
2010-03-23 22:12:10 | eric.smith | create | |
|