Public feed #889166

Miscellany

public python v1 · immutable
Raw Edit
·published 2008-02-02 18:54 UTC
rendered paste body
def my_log_traceback(severity=logging.CRITICAL):    """Write the last error's traceback to the cherrypy error log."""    from cherrypy import _cperror    h = ["  %s: %s" % (k, v) for k, v in cherrypy.request.header_list]    cherrypy.log('\nRequest Headers:\n' + '\n'.join(h) + '\n\n' + _cperror.format_exc(), "HTTP", severity=severity)cherrypy.tools.my_log_tracebacks = cherrypy.Tool('before_error_response', my_log_traceback)from logging import handlersh = handlers.SMTPHandler('localhost', 'root@localhost', 'root@localhost', 'CherryPy Error Log Entry')h.setLevel(logging.CRITICAL)cherrypy.log.error_log.addHandler(h)