This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eric.smith
Recipients eric.smith, jafo, vstinner
Date 2010-03-25.09:17:47
SpamBayes Score 0.00023892567
Marked as misclassified No
Message-id <1269508670.22.0.45613551561.issue8214@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2010-03-25 09:17:50eric.smithsetrecipients: + eric.smith, jafo, vstinner
2010-03-25 09:17:50eric.smithsetmessageid: <1269508670.22.0.45613551561.issue8214@psf.upfronthosting.co.za>
2010-03-25 09:17:48eric.smithlinkissue8214 messages
2010-03-25 09:17:47eric.smithcreate