From bea04e1fc817099115b7799f61c2d1e0b9dee5d3 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Mon, 26 Jul 2010 12:33:35 +0300 Subject: [PATCH] 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 --- bin/service/http_server.py | 3 +++ bin/service/websrv_lib.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/service/http_server.py b/bin/service/http_server.py index 75043c1cef3..fbac6fb9cf4 100644 --- a/bin/service/http_server.py +++ b/bin/service/http_server.py @@ -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', diff --git a/bin/service/websrv_lib.py b/bin/service/websrv_lib.py index b569ab57acb..b0375085d40 100644 --- a/bin/service/websrv_lib.py +++ b/bin/service/websrv_lib.py @@ -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