Commit 3650e464 by arjun.b

logging file added

parent 9607ff16
import configparser
from scripts.logging.logging import logger
try:
config = configparser.ConfigParser()
config.read(r'E:\MQTT-redis\conf\application.conf')
......@@ -12,4 +14,4 @@ try:
redis_port = config.get("redis_connect", "port")
file_name = config.get("logging", "file_name")
except configparser.NoOptionError:
print("could not find conf file")
logger.error("could not find conf file")
......@@ -3,6 +3,7 @@ from paho.mqtt import client as mqtt_client
from scripts.config.application_config import hostname, port_num, topic_name
from scripts.config.redis_connection import r
from scripts.core.handlers.get_next_doctor import get_next_doctor
from scripts.logging.logging import logger
broker = hostname
port = int(port_num)
......@@ -12,6 +13,7 @@ client.connect(broker, port, 60)
def assign_patient(patient, doctors):
try:
# Get the next doctor for the patient
next_doctor = get_next_doctor(doctors)
......@@ -29,3 +31,5 @@ def assign_patient(patient, doctors):
patient.update({"doctor": next_doctor})
r.hset(patient['patient_id'], 'doctor', next_doctor)
client.publish(topic, json.dumps(patient))
except Exception as e:
logger.error(f"could not assign patient: {e}")
from scripts.core.handlers.assign_patient import assign_patient
from scripts.logging.logging import logger
class PublishHandler:
@staticmethod
def main_handler(details):
try:
doctors = ['Dr. Smith', 'Dr. Johnson', 'Dr. Brown', "Dr. Arjun B"]
patient_details = {
"patient_id": details.id,
......@@ -12,3 +14,5 @@ class PublishHandler:
"name": details.name
}
assign_patient(patient_details, doctors)
except Exception as e:
logger.error(f"cant get patients details :{e}")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment