Skip to content

Commit 76fec62

Browse files
Copilotowndev
andcommitted
Optimize logging to avoid JSON serialization when INFO logging is disabled
Co-authored-by: owndev <69784886+owndev@users.noreply.github.com>
1 parent 7360c4c commit 76fec62

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

pipelines/azure/azure_ai_foundry.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,8 @@ def _extract_citations_from_response(
412412

413413
if citations and isinstance(citations, list):
414414
log.info(f"Extracted {len(citations)} citations from response")
415-
# Log first citation structure for debugging
416-
if citations:
415+
# Log first citation structure for debugging (only if INFO logging is enabled)
416+
if citations and log.isEnabledFor(logging.INFO):
417417
log.info(
418418
f"First citation structure: {json.dumps(citations[0], default=str)[:500]}"
419419
)
@@ -487,14 +487,15 @@ def _normalize_citation_for_openwebui(
487487
"data": citation_data,
488488
}
489489

490-
# Log the normalized citation for debugging
491-
log.info(
492-
f"Normalized citation {index}: title='{title}', "
493-
f"content_length={len(content)}, "
494-
f"url='{source_url}', "
495-
f"score={score}, "
496-
f"event={json.dumps(citation_event, default=str)[:500]}"
497-
)
490+
# Log the normalized citation for debugging (only if INFO logging is enabled)
491+
if log.isEnabledFor(logging.INFO):
492+
log.info(
493+
f"Normalized citation {index}: title='{title}', "
494+
f"content_length={len(content)}, "
495+
f"url='{source_url}', "
496+
f"score={score}, "
497+
f"event={json.dumps(citation_event, default=str)[:500]}"
498+
)
498499

499500
return citation_event
500501

0 commit comments

Comments
 (0)