1
0
mirror of https://github.com/kakwa/ldapcherry synced 2024-11-25 18:54:29 +01:00

better log handler

This commit is contained in:
kakwa 2015-06-24 22:33:28 +02:00
parent 84c3d9604f
commit be23277363

View File

@ -35,13 +35,25 @@ SESSION_KEY = '_cp_username'
# of cherrypy
def syslog_error(msg='', context='',
severity=logging.INFO, traceback=False):
if traceback:
msg += cherrypy._cperror.format_exc()
if traceback and msg == '':
msg = 'python exception'
if context == '':
cherrypy.log.error_log.log(severity, msg)
else:
cherrypy.log.error_log.log(severity,
' '.join((context, msg)))
if traceback:
try:
exc = sys.exc_info()
if exc == (None, None, None):
cherrypy.log.error_log.log(severity, msg)
import traceback
# log each line of the exception
for l in traceback.format_exception(*exc):
cherrypy.log.error_log.log(severity, l)
finally:
del exc
class LdapCherry(object):
@ -53,7 +65,7 @@ class LdapCherry(object):
)
else:
cherrypy.log.error(
msg = "unkwon exception '%(e)s'" % { 'e' : str(e) },
msg = "unkwon exception: '%(e)s'" % { 'e' : str(e) },
severity = logging.ERROR
)
# log the traceback as 'debug'