From 5d40927464917bbeb74687e323d9af1f87bd6fb0 Mon Sep 17 00:00:00 2001 From: Jason Schroth Date: Fri, 2 Aug 2024 17:11:11 -0700 Subject: [PATCH] Adding structured data (#5034) * Adding structured data Recommended update to structured data being added to the logging instead of including it in the message directly * comma fix --- src/dispatch/case/flows.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/dispatch/case/flows.py b/src/dispatch/case/flows.py index eab95d2244c3..ed52232c185f 100644 --- a/src/dispatch/case/flows.py +++ b/src/dispatch/case/flows.py @@ -542,7 +542,10 @@ def case_status_transition_flow_dispatcher( db_session: Session, ): """Runs the correct flows based on the current and previous status of the case.""" - log.info(f"Transitioning Status for Case #{case.id} from {previous_status} to {current_status}") + log.info( + "Transitioning Case status", + extra={"case_id": case.id, "previous_status": previous_status, "current_status": current_status} + ) match (previous_status, current_status): case (CaseStatus.closed, CaseStatus.new): # Closed -> New @@ -569,7 +572,10 @@ def case_status_transition_flow_dispatcher( case (_, CaseStatus.triage): # Any -> Triage/ - log.warning(f"Unexpected Status Transition for Case #{case.id} from {previous_status} to {current_status}") + log.warning( + "Unexpected previous state for Case transition to Triage state.", + extra={"case_id": case.id, "previous_status": previous_status, "current_status": current_status} + ) case (CaseStatus.new, CaseStatus.escalated): # New -> Escalated