From 7cd29e945480ddf956ebb52c254d633cd553850c Mon Sep 17 00:00:00 2001 From: curo1305 Date: Thu, 4 Jun 2026 23:12:20 +0200 Subject: [PATCH] fix(06): WR-07 replace print() with structlog for cloud delete errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace print(..., file=sys.stderr) with structlog.get_logger(__name__) .warning("cloud_delete_failed", ...) so cloud delete errors carry a correlation ID, are picked up by promtail, and appear in Loki — matching the Phase 6 goal of routing all logging through structlog. Co-Authored-By: Claude Sonnet 4.6 --- backend/api/documents.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/api/documents.py b/backend/api/documents.py index 767d0b1..9b11c8f 100644 --- a/backend/api/documents.py +++ b/backend/api/documents.py @@ -26,6 +26,9 @@ import uuid from pathlib import Path from typing import Optional +import structlog as _structlog +_log = _structlog.get_logger(__name__) + from fastapi import APIRouter, Depends, Form, HTTPException, Query, Request, UploadFile, File, status from fastapi.responses import JSONResponse, StreamingResponse from pydantic import BaseModel, Field, field_validator @@ -668,8 +671,7 @@ async def delete_document( cloud_backend = await get_storage_backend_for_document(doc, current_user, session) await cloud_backend.delete_object(doc.object_key) except Exception as exc: - import sys - print(f"[cloud-delete] provider error: {exc}", file=sys.stderr) + _log.warning("cloud_delete_failed", provider=doc.storage_backend, error=str(exc)) return JSONResponse( status_code=200, content={