From e4893a22c2616d4c6bb8c0215dc0756370cee27e Mon Sep 17 00:00:00 2001 From: Finn Christiansen Date: Sat, 21 Sep 2024 12:38:46 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8A=20better=20logging?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- matrix_bot_invitation_mailer/__main__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/matrix_bot_invitation_mailer/__main__.py b/matrix_bot_invitation_mailer/__main__.py index 0f4471e..43b6023 100644 --- a/matrix_bot_invitation_mailer/__main__.py +++ b/matrix_bot_invitation_mailer/__main__.py @@ -105,9 +105,9 @@ The link will be valid for 7 days.""".format(os.getenv("REGISTRATION_URL") + res # Send the email server.sendmail(sender_email, receiver_email, msg.as_string()) - print("Email sent successfully") + logging.info("Email sent successfully") except Exception as e: - print(f"Error: {e}") + logging.error("Error sending mail: {}".format(e)) finally: # Close the connection server.quit() @@ -118,7 +118,7 @@ while True: bot.run() except ServerDisconnectedError: time.sleep(5) - print("connection lost, reconnecting in 5 seconds...") + logging.info("connection lost, reconnecting in 5 seconds...") except KeyboardInterrupt: - print("exiting...") + logging.info("exiting...") sys.exit(0)