From c7b333c545adf8958ec97771e6816ceb5e83f524 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 25 Feb 2019 16:56:41 +0000 Subject: [PATCH 1/2] Log tracebacks correctly --- synapse/federation/federation_server.py | 5 +++-- synapse/handlers/pagination.py | 6 +++++- synapse/http/server.py | 8 ++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/synapse/federation/federation_server.py b/synapse/federation/federation_server.py index 3da86d4ba6..8f45c2badf 100644 --- a/synapse/federation/federation_server.py +++ b/synapse/federation/federation_server.py @@ -239,8 +239,9 @@ class FederationServer(FederationBase): f = failure.Failure() pdu_results[event_id] = {"error": str(e)} logger.error( - "Failed to handle PDU %s: %s", - event_id, f.getTraceback().rstrip(), + "Failed to handle PDU %s", + event_id, + exc_info=(f.type, f.value, f.getTracebackObject()), ) yield concurrently_execute( diff --git a/synapse/handlers/pagination.py b/synapse/handlers/pagination.py index 084c1503da..e4fdae9266 100644 --- a/synapse/handlers/pagination.py +++ b/synapse/handlers/pagination.py @@ -136,7 +136,11 @@ class PaginationHandler(object): logger.info("[purge] complete") self._purges_by_id[purge_id].status = PurgeStatus.STATUS_COMPLETE except Exception: - logger.error("[purge] failed: %s", Failure().getTraceback().rstrip()) + f = Failure() + logger.error( + "[purge] failed", + exc_info=(f.type, f.value, f.getTracebackObject()), + ) self._purges_by_id[purge_id].status = PurgeStatus.STATUS_FAILED finally: self._purges_in_progress_by_room.discard(room_id) diff --git a/synapse/http/server.py b/synapse/http/server.py index 6c67a25a11..16fb7935da 100644 --- a/synapse/http/server.py +++ b/synapse/http/server.py @@ -169,18 +169,18 @@ def _return_html_error(f, request): ) else: logger.error( - "Failed handle request %r: %s", + "Failed handle request %r", request, - f.getTraceback().rstrip(), + exc_info=(f.type, f.value, f.getTracebackObject()), ) else: code = http_client.INTERNAL_SERVER_ERROR msg = "Internal server error" logger.error( - "Failed handle request %r: %s", + "Failed handle request %r", request, - f.getTraceback().rstrip(), + exc_info=(f.type, f.value, f.getTracebackObject()), ) body = HTML_ERROR_TEMPLATE.format( From 1d0f2ec8127fa74db41316f588c8a202c9e91275 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 25 Feb 2019 17:02:31 +0000 Subject: [PATCH 2/2] Newsfile --- changelog.d/4669.misc | 2 +- changelog.d/4737.misc | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changelog.d/4737.misc diff --git a/changelog.d/4669.misc b/changelog.d/4669.misc index 00a1a940ae..d5d0e27731 100644 --- a/changelog.d/4669.misc +++ b/changelog.d/4669.misc @@ -1 +1 @@ -Cleanup request exception logging +Cleanup request exception logging. diff --git a/changelog.d/4737.misc b/changelog.d/4737.misc new file mode 100644 index 0000000000..d5d0e27731 --- /dev/null +++ b/changelog.d/4737.misc @@ -0,0 +1 @@ +Cleanup request exception logging.