From c97fa4fe96ff066c7f886eef0a5e8dba87d9a506 Mon Sep 17 00:00:00 2001 From: Gleb Mikhaylov Date: Tue, 27 Aug 2019 11:06:47 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=BF=D0=B8=D1=81=D1=8C=20=D0=BD=D0=B0=D0=BF=D1=80?= =?UTF-8?q?=D1=8F=D0=BC=D1=83=D1=8E=20=D0=B2=20=D1=84=D0=B0=D0=B9=D0=BB,?= =?UTF-8?q?=20=D0=B1=D0=B5=D0=B7=20=D0=BB=D0=BE=D0=B3=D0=B3=D0=B5=D1=80?= =?UTF-8?q?=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/payment/tasks.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/apps/payment/tasks.py b/apps/payment/tasks.py index 092a81de..42b02843 100644 --- a/apps/payment/tasks.py +++ b/apps/payment/tasks.py @@ -1,6 +1,7 @@ import logging import requests import json +import datetime from mixpanel import Mixpanel @@ -70,11 +71,19 @@ def transaction_to_roistat(user_id, payment_id, event_name, amount, time, status except: resp_json = None - if resp.status_code != 200 or not resp_json or not resp_json.get('processed'): - logger.error('TRANSACTION_TO_ROISTAT for payment # %d, %s RUB: %s' % ( - payment_id, amount, resp.text)) - logger_roistat.debug('TRANSACTION_TO_ROISTAT for payment # %d, %s RUB: %s' % ( - payment_id, amount, resp.text)) - else: - logger.info('TRANSACTION_TO_ROISTAT: ' + str(resp.text)) - logger_roistat.debug('TRANSACTION_TO_ROISTAT: ' + str(resp.text)) + with open("./roistat.log", "a") as text_file: + + if resp.status_code != 200 or not resp_json or not resp_json.get('processed'): + logger.error('TRANSACTION_TO_ROISTAT for payment # %d, %s RUB: %s' % ( + payment_id, amount, resp.text)) + logger_roistat.debug('TRANSACTION_TO_ROISTAT for payment # %d, %s RUB: %s' % ( + payment_id, amount, resp.text)) + + text_file.write(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') + ' TRANSACTION_TO_ROISTAT for payment # %d, %s RUB: %s \n' % ( + payment_id, amount, resp.text)) + else: + logger.info('TRANSACTION_TO_ROISTAT: ' + str(resp.text)) + logger_roistat.debug('TRANSACTION_TO_ROISTAT: ' + str(resp.text)) + + text_file.write(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') + ' TRANSACTION_TO_ROISTAT for payment # %d, %s RUB: %s \n' % ( + payment_id, amount, resp.text))