From 54d676a7cce73833bf7ae9266836c8afa9a555b9 Mon Sep 17 00:00:00 2001 From: Chinenye Nmoh Date: Tue, 4 Nov 2025 15:12:35 +0100 Subject: [PATCH] added logs --- app/routes/autocall.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/routes/autocall.py b/app/routes/autocall.py index 37717da..2a5c96d 100644 --- a/app/routes/autocall.py +++ b/app/routes/autocall.py @@ -120,8 +120,10 @@ def direct_loan(): }), 400 # Check if the loan exists + logger.info(f"Checking if loan with transaction id {data['transactionId']} exists") loan = LoanService.get_loan_by_transaction_id(transaction_id=data['transactionId']) if not loan: + logger.warning(f"Loan with transaction id {data['transactionId']} does not exist") return jsonify({ "status": "error", "message": f"Loan with transaction id {data['transactionId']} does not exist" @@ -165,8 +167,10 @@ def direct_repayment(): }), 400 # Check if the loan exists + logger.info(f"Checking if loan with transaction id {data['transactionId']} exists") loan = LoanService.get_loan_by_transaction_id(transaction_id=data['transactionId']) if not loan: + logger.info(f"Loan with transaction id {data['transactionId']} does not exist") return jsonify({ "status": "error", "message": f"Loan with transaction id {data['transactionId']} does not exist" @@ -176,6 +180,7 @@ def direct_repayment(): # check if loan has been repaid if loan_data.get("status") == LoanStatus.REPAID and loan_data.get("balance") <= 0: + logger.info(f"Loan with Id {loan_data.get('debtId')} has been repaid") return jsonify({ "status": "error", "message": f"loan with Id {loan_data.get('debtId')} has been repaid" @@ -196,6 +201,7 @@ def direct_repayment(): try: repayment = RepaymentService.create_repayment(repayment_data) + logger.info(f"Repayment created: {repayment}") except Exception as e: db.session.rollback() logger.error(f"Repayment creation raised exception: {e}") -- 2.34.1