Skip to content

Commit

Permalink
chore: 이상상황 전송시 로그 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
sukkyun2 committed Aug 3, 2024
1 parent 31e5583 commit 3508b94
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/history.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import base64
import logging
from collections import Counter
from datetime import datetime
from io import BytesIO
Expand All @@ -12,6 +13,8 @@
from app.config import settings
from model.detect import Detection, DetectionResult

logging.basicConfig(level=logging.INFO)


class HistorySaveRequest(BaseModel):
localDateTime: str
Expand All @@ -33,10 +36,13 @@ def summary_detections():
counter = Counter(list(map(lambda d: d.class_name, detections)))
return ' '.join(f'{k} {v}' for k, v in counter.items())

super().__init__(localDateTime=datetime.now().isoformat(), label=summary_detections(), base64Image=convert_base64())
super().__init__(localDateTime=datetime.now().isoformat(), label=summary_detections(),
base64Image=convert_base64())


async def async_save_history(result: DetectionResult):
logging.info("이상상황이 발생하여 이력을 저장합니다")

asyncio.create_task(
save_history(HistorySaveRequest(image=result.get_image(), detections=result.detections))
)
Expand Down

0 comments on commit 3508b94

Please sign in to comment.