Skip to content

Commit 2317df6

Browse files
committed
refactor(logging): standardize log format with additional context
1 parent f353ba0 commit 2317df6

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/server/metrics_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def start_metrics_server(host: str = "127.0.0.1", port: int = 9090) -> None:
5353
None
5454
5555
"""
56-
logger.info("Starting metrics server on %s:%s", host, port)
56+
logger.info("Starting metrics server", extra={"host": host, "port": port})
5757

5858
# Configure uvicorn to suppress startup messages to avoid duplicates
5959
# since the main server already shows similar messages

src/server/query_processor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ async def _check_s3_cache(
114114
)
115115
except Exception as exc:
116116
# Log the exception but don't fail the entire request
117-
logger.warning("S3 cache check failed, falling back to normal cloning: %s", exc)
117+
logger.warning("S3 cache check failed, falling back to normal cloning", extra={"error": str(exc)})
118118

119119
return None
120120

@@ -168,7 +168,7 @@ def _store_digest_content(
168168
logger.info("Successfully uploaded metadata to S3")
169169
except Exception as metadata_exc:
170170
# Log the error but don't fail the entire request
171-
logger.warning("Failed to upload metadata to S3: %s", metadata_exc)
171+
logger.warning("Failed to upload metadata to S3", extra={"error": str(metadata_exc)})
172172

173173
# Store S3 URL in query for later use
174174
query.s3_url = s3_url

src/server/s3_utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,14 +371,14 @@ def get_metadata_from_s3(s3_file_path: str) -> S3Metadata | None:
371371
# Object doesn't exist if we get a 404 error
372372
error_code = err.response.get("Error", {}).get("Code")
373373
if error_code == "404":
374-
logger.info("Metadata file not found: %s", metadata_file_path)
374+
logger.info("Metadata file not found", extra={"metadata_file_path": metadata_file_path})
375375
return None
376376
# Log other errors but don't fail
377-
logger.warning("Failed to retrieve metadata from S3: %s", err)
377+
logger.warning("Failed to retrieve metadata from S3", extra={"error": str(err)})
378378
return None
379379
except Exception as exc:
380380
# For any other exception, log and return None
381-
logger.warning("Unexpected error retrieving metadata from S3: %s", exc)
381+
logger.warning("Unexpected error retrieving metadata from S3", extra={"error": str(exc)})
382382
return None
383383

384384

@@ -497,7 +497,7 @@ def get_s3_url_for_ingest_id(ingest_id: UUID) -> str | None:
497497
498498
"""
499499
if not is_s3_enabled():
500-
logger.debug("S3 not enabled, skipping URL lookup for ingest_id: %s", ingest_id)
500+
logger.debug("S3 not enabled, skipping URL lookup", extra={"ingest_id": str(ingest_id)})
501501
return None
502502

503503
logger.info("Starting S3 URL lookup for ingest ID", extra={"ingest_id": str(ingest_id)})

0 commit comments

Comments
 (0)