From d8785b803a529f212fc8cf24ecbd89cf359386bf Mon Sep 17 00:00:00 2001 From: Jose Borreguero Date: Wed, 28 Aug 2024 16:04:17 -0400 Subject: [PATCH] Add connection success logs in database and broker modules Added print statements to log successful connections in both PostgreSQL and broker connection attempts. This will aid in debugging and confirming when connections are successfully established. Signed-off-by: Jose Borreguero --- src/webmonchow/amq/broadcast.py | 1 + src/webmonchow/pv/broadcast.py | 1 + 2 files changed, 2 insertions(+) diff --git a/src/webmonchow/amq/broadcast.py b/src/webmonchow/amq/broadcast.py index d5d3420..3b0b235 100644 --- a/src/webmonchow/amq/broadcast.py +++ b/src/webmonchow/amq/broadcast.py @@ -109,6 +109,7 @@ def connect_to_broker(broker, user, password, attempts=None, interval=5.0): while attempts is None or attempt_number < attempts: try: conn = conn.connect(user, password, wait=True) + print(f"Connected to {broker}") return conn except stomp.exception.ConnectFailedException as e: attempt_number += 1 diff --git a/src/webmonchow/pv/broadcast.py b/src/webmonchow/pv/broadcast.py index 1a65d74..0bec5dd 100644 --- a/src/webmonchow/pv/broadcast.py +++ b/src/webmonchow/pv/broadcast.py @@ -134,6 +134,7 @@ def connect_to_database(database, user, password, host, port, attempts=None, int while attempts is None or attempt_number < attempts: try: conn = psycopg2.connect(database=database, user=user, password=password, host=host, port=port) + print(f"Connected to {database}") return conn except psycopg2.OperationalError as e: attempt_number += 1