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
Date 2010-03-23.22:12:10
SpamBayes Score 3.5977053e-05
Marked as misclassified No
Message-id <1269382333.64.0.598164519082.issue8214@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2010-03-23 22:12:13eric.smithsetrecipients: + eric.smith, jafo
2010-03-23 22:12:13eric.smithsetmessageid: <1269382333.64.0.598164519082.issue8214@psf.upfronthosting.co.za>
2010-03-23 22:12:11eric.smithlinkissue8214 messages
2010-03-23 22:12:10eric.smithcreate