Message101681
Good point. So that makes the implementation more like:
import traceback
import syslog
import sys
def syslog_exception(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)
def logexceptions(chain=True):
# Should we chain to the existing sys.excepthook?
current_hook = sys.excepthook if chain else None
def hook(etype, evalue, etb):
if current_hook:
current_hook(etype, evalue, etb)
syslog_exception(etype, evalue, etb)
sys.excepthook = hook
We could then make syslog_exception take a tuple instead of the 3 values. I'm not sure which is more convenient, or more widely used in other APIs.
Once it's moved into syslog, maybe syslog_exception named syslog.log_exception. |
|
Date |
User |
Action |
Args |
2010-03-25 09:17:50 | eric.smith | set | recipients:
+ eric.smith, jafo, vstinner |
2010-03-25 09:17:50 | eric.smith | set | messageid: <1269508670.22.0.45613551561.issue8214@psf.upfronthosting.co.za> |
2010-03-25 09:17:48 | eric.smith | link | issue8214 messages |
2010-03-25 09:17:47 | eric.smith | create | |
|