Websrv_lib, http_server: have special exception logging
the websrv_lib must conform to the BaseHTTPServer API, that does not define an exception logging function, nor does it encourage the use of individual pythonic loggers. So, have a function that is optionally called, upon exception. This improves much over the 'log_error()' call, because it allows us to see all those bugs that would make a http method fail. bzr revid: p_christ@hol.gr-20100726093335-e3hxsri766o2fzxp
This commit is contained in:
@@ -106,6 +106,9 @@ class HttpLogHandler:
|
||||
|
||||
def log_error(self, format, *args):
|
||||
self._logger.error(format % args)
|
||||
|
||||
def log_exception(self, format, *args):
|
||||
self._logger.exception(format, *args)
|
||||
|
||||
def log_request(self, code='-', size='-'):
|
||||
self._logger.log(netsvc.logging.DEBUG_RPC, '"%s" %s %s',
|
||||
|
||||
@@ -253,7 +253,10 @@ class MultiHTTPHandler(FixSendError, HttpOptions, BaseHTTPRequestHandler):
|
||||
except (AuthRejectedExc, AuthRequiredExc):
|
||||
raise
|
||||
except Exception, e:
|
||||
self.log_error("Could not run %s: %s", mname, e)
|
||||
if hasattr(self, 'log_exception'):
|
||||
self.log_exception("Could not run %s", mname)
|
||||
else:
|
||||
self.log_error("Could not run %s: %s", mname, e)
|
||||
self.send_error(500, "Internal error")
|
||||
# may not work if method has already sent data
|
||||
fore.close_connection = 1
|
||||
|
||||
Reference in New Issue
Block a user