From b06c9644d482cbcd099c368336b4cc5dddcf7615 Mon Sep 17 00:00:00 2001 From: demo-bot Date: Sun, 9 Aug 2026 15:49:40 +0000 Subject: [PATCH] decomposer: generate deliverable files for Define the service contract and project architecture for the FastAPI endpoint monitoring service.; Implement the typed monitor CRUD API and concurrency-safe in-memory state according to the service design.; Implement secure on-demand endpoint checks with status updates, latency measurement, robust error handling, and redacted structured logs.; Add operational API endpoints and environment-driven runtime configuration to the monitoring service.; Create automated tests for the monitoring service.; Package the service with Docker and developer documentation.; Validate the complete project. --- app/logging.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/logging.py b/app/logging.py index f5081af..6106137 100644 --- a/app/logging.py +++ b/app/logging.py @@ -1,27 +1,27 @@ import json import logging -from datetime import UTC, datetime +from datetime import datetime, timezone from typing import Any class JsonFormatter(logging.Formatter): def format(self, record: logging.LogRecord) -> str: - payload: dict[str, Any] = { - "timestamp": datetime.now(UTC).isoformat(), + data: dict[str, Any] = { + "timestamp": datetime.now(timezone.utc).isoformat(), "level": record.levelname, "logger": record.name, "message": record.getMessage(), } - for key in ("event", "monitor_id", "url", "state", "latency_ms", "status_code"): + for key in ("event", "monitor_id", "url", "outcome", "error_code", "latency_ms"): value = getattr(record, key, None) if value is not None: - payload[key] = value - return json.dumps(payload, default=str) + data[key] = value + return json.dumps(data, separators=(",", ":"), default=str) def configure_logging(level: str) -> None: handler = logging.StreamHandler() handler.setFormatter(JsonFormatter()) root = logging.getLogger() - root.handlers = [handler] + root.handlers[:] = [handler] root.setLevel(level.upper())