From b2200a869007f1b10b6f7d57618f1fedb3ad8908 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Wed, 20 Feb 2019 11:36:50 +0000 Subject: [PATCH] Logging improvements for the pusher (#4691) --- changelog.d/4691.misc | 1 + synapse/push/httppusher.py | 16 ++++++++-------- synapse/push/pusher.py | 11 ++++++----- 3 files changed, 15 insertions(+), 13 deletions(-) create mode 100644 changelog.d/4691.misc diff --git a/changelog.d/4691.misc b/changelog.d/4691.misc new file mode 100644 index 000000000..8eb825edf --- /dev/null +++ b/changelog.d/4691.misc @@ -0,0 +1 @@ +Improve the logging in the pusher process. diff --git a/synapse/push/httppusher.py b/synapse/push/httppusher.py index 87fa7f006..98d8d9560 100644 --- a/synapse/push/httppusher.py +++ b/synapse/push/httppusher.py @@ -333,10 +333,10 @@ class HttpPusher(object): defer.returnValue([]) try: resp = yield self.http_client.post_json_get_json(self.url, notification_dict) - except Exception: - logger.warn( - "Failed to push event %s to %s", - event.event_id, self.name, exc_info=True, + except Exception as e: + logger.warning( + "Failed to push event %s to %s: %s %s", + event.event_id, self.name, type(e), e, ) defer.returnValue(False) rejected = [] @@ -367,10 +367,10 @@ class HttpPusher(object): } try: resp = yield self.http_client.post_json_get_json(self.url, d) - except Exception: - logger.warn( - "Failed to send badge count to %s", - self.name, exc_info=True, + except Exception as e: + logger.warning( + "Failed to send badge count to %s: %s %s", + self.name, type(e), e, ) defer.returnValue(False) rejected = [] diff --git a/synapse/push/pusher.py b/synapse/push/pusher.py index fcee6d9d7..368d5094b 100644 --- a/synapse/push/pusher.py +++ b/synapse/push/pusher.py @@ -52,11 +52,12 @@ class PusherFactory(object): logger.info("defined email pusher type") def create_pusher(self, pusherdict): - logger.info("trying to create_pusher for %r", pusherdict) - - if pusherdict['kind'] in self.pusher_types: - logger.info("found pusher") - return self.pusher_types[pusherdict['kind']](self.hs, pusherdict) + kind = pusherdict['kind'] + f = self.pusher_types.get(kind, None) + if not f: + return None + logger.info("creating %s pusher for %r", kind, pusherdict) + return f(self.hs, pusherdict) def _create_email_pusher(self, _hs, pusherdict): app_name = self._app_name_from_pusherdict(pusherdict)