fix(06): WR-07 replace print() with structlog for cloud delete errors

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 <noreply@anthropic.com>
This commit is contained in:
curo1305
2026-06-04 23:15:49 +02:00
co-authored by Claude Sonnet 4.6
parent b0d2406acd
commit 7cd29e9454
+4 -2
View File
@@ -26,6 +26,9 @@ import uuid
from pathlib import Path from pathlib import Path
from typing import Optional 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 import APIRouter, Depends, Form, HTTPException, Query, Request, UploadFile, File, status
from fastapi.responses import JSONResponse, StreamingResponse from fastapi.responses import JSONResponse, StreamingResponse
from pydantic import BaseModel, Field, field_validator 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) cloud_backend = await get_storage_backend_for_document(doc, current_user, session)
await cloud_backend.delete_object(doc.object_key) await cloud_backend.delete_object(doc.object_key)
except Exception as exc: except Exception as exc:
import sys _log.warning("cloud_delete_failed", provider=doc.storage_backend, error=str(exc))
print(f"[cloud-delete] provider error: {exc}", file=sys.stderr)
return JSONResponse( return JSONResponse(
status_code=200, status_code=200,
content={ content={