From a872fae21fe54dd06a9a8a58be865d70d473e055 Mon Sep 17 00:00:00 2001 From: Aakash Singh Date: Mon, 20 May 2024 22:26:38 +0530 Subject: [PATCH] Only log the error message in uptime monitor tasks --- care/facility/tasks/asset_monitor.py | 8 ++++---- care/facility/tasks/location_monitor.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/care/facility/tasks/asset_monitor.py b/care/facility/tasks/asset_monitor.py index ef095c1c71..df302b399e 100644 --- a/care/facility/tasks/asset_monitor.py +++ b/care/facility/tasks/asset_monitor.py @@ -69,8 +69,8 @@ def check_asset_status(): ) else: result = asset_class.api_get(asset_class.get_url("devices/status")) - except Exception: - logger.warn(f"Middleware {resolved_middleware} is down", exc_info=True) + except Exception as e: + logger.warn(f"Middleware {resolved_middleware} is down", e) # If no status is returned, setting default status as down if not result or "error" in result: @@ -116,5 +116,5 @@ def check_asset_status(): status=new_status.value, timestamp=status_record.get("time", timezone.now()), ) - except Exception: - logger.error("Error in Asset Status Check", exc_info=True) + except Exception as e: + logger.error("Error in Asset Status Check", e) diff --git a/care/facility/tasks/location_monitor.py b/care/facility/tasks/location_monitor.py index e3ff104187..de89d5b451 100644 --- a/care/facility/tasks/location_monitor.py +++ b/care/facility/tasks/location_monitor.py @@ -53,8 +53,8 @@ def check_location_status(): if result: new_status = AvailabilityStatus.OPERATIONAL - except Exception: - logger.warn(f"Middleware {resolved_middleware} is down", exc_info=True) + except Exception as e: + logger.warn(f"Middleware {resolved_middleware} is down", e) # Fetching the last record of the location last_record = ( @@ -75,5 +75,5 @@ def check_location_status(): timestamp=timezone.now(), ) logger.info(f"Location {location.external_id} status: {new_status.value}") - except Exception: - logger.error("Error in Location Status Check", exc_info=True) + except Exception as e: + logger.error("Error in Location Status Check", e)