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:
P. Christeas
2010-07-26 12:33:35 +03:00
parent 40758b5222
commit bea04e1fc8
2 changed files with 7 additions and 1 deletions
+3
View File
@@ -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',
+4 -1
View File
@@ -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