Prefix apple-specific APNS logs with APNS:

(imported from commit 2fa866b3a626c3e42f340bc68e8bc27aef6fd521)
This commit is contained in:
Leo Franchi 2014-01-21 15:15:28 -05:00
parent d4aece75a5
commit 226d894257
1 changed files with 5 additions and 5 deletions

View File

@ -43,27 +43,27 @@ def send_apple_push_notification(user, alert, **extra_data):
tokens = [b64_to_hex(device.token) for device in tokens = [b64_to_hex(device.token) for device in
PushDeviceToken.objects.filter(user=user, kind=PushDeviceToken.APNS)] PushDeviceToken.objects.filter(user=user, kind=PushDeviceToken.APNS)]
logging.info("Sending apple push notification to devices: %s" % (tokens,)) logging.info("APNS: Sending apple push notification to devices: %s" % (tokens,))
message = Message(tokens, alert=alert, **extra_data) message = Message(tokens, alert=alert, **extra_data)
apns_client = APNs(connection) apns_client = APNs(connection)
ret = apns_client.send(message) ret = apns_client.send(message)
if not ret: if not ret:
logging.warning("Failed to send push notification for clients %s" % (tokens,)) logging.warning("APNS: Failed to send push notification for clients %s" % (tokens,))
return return
for token, reason in ret.failed.items(): for token, reason in ret.failed.items():
code, errmsg = reason code, errmsg = reason
logging.warning("Failed to deliver APNS notification to %s, reason: %s" % (token, errmsg)) logging.warning("APNS: Failed to deliver APNS notification to %s, reason: %s" % (token, errmsg))
# Check failures not related to devices. # Check failures not related to devices.
for code, errmsg in ret.errors: for code, errmsg in ret.errors:
logging.warning("Unknown error when delivering APNS: %s" % (errmsg,)) logging.warning("APNS: Unknown error when delivering APNS: %s" % (errmsg,))
if ret.needs_retry(): if ret.needs_retry():
# TODO handle retrying by potentially scheduling a background job # TODO handle retrying by potentially scheduling a background job
# or re-queueing # or re-queueing
logging.warning("APNS delivery needs a retry but ignoring") logging.warning("APNS: delivery needs a retry but ignoring")
# NOTE: This is used by the check_apns_tokens manage.py command. Do not call it otherwise, as the # NOTE: This is used by the check_apns_tokens manage.py command. Do not call it otherwise, as the
# feedback() call can take up to 15s # feedback() call can take up to 15s