Log charge errors at INFO level
authorSybren A. Stüvel <sybren@stuvel.eu>
Thu, 3 Jan 2019 11:40:13 +0000 (12:40 +0100)
committerSybren A. Stüvel <sybren@stuvel.eu>
Thu, 3 Jan 2019 11:40:13 +0000 (12:40 +0100)
Such errors happen very frequently (not enough money on a credit card, etc.)
so they shouldn't trigger Sentry events or send mails to admins.

looper/clock.py

index ec6cdb9c7cf93ebead09e101bbee12a334631ad4..bb4ffc028ba7bcef1522335dd85e05707781f170 100644 (file)
@@ -391,11 +391,12 @@ class Clock(AbstractClock):
         """Update the order and transaction for the failure."""
         max_attempts: int = settings.LOOPER_CLOCK_MAX_AUTO_ATTEMPTS
 
+        # This is logged at info level, because it is actually expected to happen frequently.
         my_log = self.log.getChild('on_collect_automatic_failed')
         msg = f'Error charging transaction {trans.pk} for renewal order {order.pk} for ' \
               f'subscription {order.subscription.pk}, attempt {order.collection_attempts} ' \
               f'of {max_attempts}: {trans.failure_message}'
-        my_log.error(msg)
+        my_log.info(msg)
 
         if order.collection_attempts >= max_attempts:
             admin_log.attach_log_entry(