From 68184858b495281bd2b402a833077db09b239a95 Mon Sep 17 00:00:00 2001 From: Unrud Date: Wed, 21 Jun 2017 09:48:59 +0200 Subject: [PATCH] Add request method and path to error message --- radicale/__init__.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/radicale/__init__.py b/radicale/__init__.py index 22a79a1..8e5bef6 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -297,8 +297,16 @@ class Application: try: status, headers, answers = self._handle_request(environ) except Exception as e: - self.logger.error("An exception occurred during request: %s", - e, exc_info=True) + try: + method = str(environ["REQUEST_METHOD"]) + except Exception: + method = "unknown" + try: + path = str(environ.get("PATH_INFO", "")) + except Exception: + path = "" + self.logger.error("An exception occurred during %s request on %r: " + "%s", method, path, e, exc_info=True) status, headers, answer = INTERNAL_SERVER_ERROR status = "%d %s" % ( status, client.responses.get(status, "Unknown"))