Commits

Matthew Schinckel committed 163a828

Use sms-gateway logger

Comments (0)

Files changed (1)

 
 @csrf_exempt
 def update_delivery_status(request):
-    logging.debug("Status update received.")
-    logging.debug("%s" % request.GET)
+    logger.debug("Status update received. %s" % request.GET)
+
     data = {}
     for k,v in request.GET.items():
         if isinstance(v, list) and len(v) == 1:
         else:
             data[k] = v
     
-    logging.debug('%s' % data)
+    logger.debug('%s' % data)
     
     msg = Message.objects.get_matching_message(data)
     
         # Need to respond with OK, else remote server will keep trying.
         return HttpResponse('OK')
         
-    logging.debug("Found message %i" % msg.pk)
+    logger.debug("Found message %i" % msg.pk)
     gateway = msg.gateway
     
     if  not gateway.status_mapping or (
         msg.status = "Failed"
     else:
         msg.status = gateway.status_mapping[data.get(gateway.status_status)]
-    logging.debug("Updated status to %s" % msg.status)
+    logger.debug("Updated status to %s" % msg.status)
     if msg.status == "Delivered":
         if gateway.status_date_format:
             msg.delivery_date = datetime.datetime.strptime(
             msg.delivery_date = datetime.datetime.fromtimestamp(
                 float(data.get(gateway.status_date))
             )
-        logging.debug("Message was delivered at %s" % msg.delivery_date)
+        logger.debug("Message was delivered at %s" % msg.delivery_date)
     else:
         msg.status_message = data.get(gateway.status_error_code)
-        logging.debug("Error message was %s" % msg.status_message)
+        logger.debug("Error message was %s" % msg.status_message)
     
     # If the gateway told us how much it cost, we can store that.
     if gateway.charge_keyword:
 
 @csrf_exempt
 def handle_reply(request):
-    logging.debug("SMS Reply received.")
+    logger.debug("SMS Reply received.")
     data = {}
     for k,v in request.GET.items():
         if isinstance(v, list) and len(v) == 1:
         logger.error("Original message could not be found: %s" % data)
         return HttpResponse('OK')
         
-    logging.debug("Found message %i" % msg.pk)
+    logger.debug("Found message %i" % msg.pk)
     gateway = msg.gateway
     if gateway.reply_date_format:
         reply_date = datetime.datetime.strptime(
         content=data.get(gateway.reply_content),
         date=reply_date,
     )
-    logging.debug("Reply created")
+    logger.debug("Reply created")
 
-    logging.debug("Message content was: %s" % reply.content)
+    logger.debug("Message content was: %s" % reply.content)
     
     if msg.reply_callback:
-        logging.debug("Callback found, running that.")
+        logger.debug("Callback found, running that.")
         msg.reply_callback(reply)
     
     return HttpResponse('OK')