Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
bug: do not try to JSON serialize log output
Browse files Browse the repository at this point in the history
Some info that needs to be logged is not JSON serializable. Use repr()
for now.

closes #631
  • Loading branch information
jrconlin committed Aug 26, 2016
1 parent 2f783fe commit 9861edb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions autopush/router/gcm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""GCM Router"""
import gcmclient
import json

from twisted.internet.threads import deferToThread
from twisted.logger import Logger
Expand Down Expand Up @@ -158,7 +157,7 @@ def _process_reply(self, reply, uaid_data):
self.metrics.increment("updates.client.bridge.gcm.failed.failure",
self._base_tags)
self.log.info("GCM failures: {failed()}",
failed=lambda: json.dumps(reply.failed.items()))
failed=lambda: repr(reply.failed.items()))
self.router_table.register_user(
{"uaid": uaid_data.get('uaid'),
"router_type": uaid_data.get("router_type", "gcm"),
Expand All @@ -173,7 +172,7 @@ def _process_reply(self, reply, uaid_data):
# retries:
if reply.needs_retry():
self.log.warn("GCM retry requested: {failed()}",
failed=lambda: json.dumps(reply.failed.items()))
failed=lambda: repr(reply.failed.items()))
self.metrics.increment("updates.client.bridge.gcm.failed.retry",
self._base_tags)
raise RouterException("GCM failure to deliver, retry",
Expand Down
4 changes: 2 additions & 2 deletions autopush/router/webpush.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ def preflight_check(self, uaid_data, channel_id):
uaid = uaid_data["uaid"]
if 'current_month' not in uaid_data:
self.log.info("Record missing 'current_month' {record}",
record=json.dumps(uaid_data))
record=repr(uaid_data))
yield deferToThread(self.ap_settings.router.drop_user, uaid)
raise RouterException("No such subscription", status_code=410,
log_exception=False, errno=106)

month_table = uaid_data["current_month"]
if month_table not in self.ap_settings.message_tables:
self.log.info("'current_month' out of scope: {record}",
record=json.dumps(uaid_data))
record=repr(uaid_data))
yield deferToThread(self.ap_settings.router.drop_user, uaid)
raise RouterException("No such subscription", status_code=410,
log_exception=False, errno=106)
Expand Down

0 comments on commit 9861edb

Please sign in to comment.