added logging and reworked Series query
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
import logging
|
||||
import traceback
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import HTTPException, UploadFile, status
|
||||
from icecream import ic
|
||||
|
||||
from app.db.base_queries import BaseQueries
|
||||
|
||||
@@ -26,3 +32,15 @@ class BaseController:
|
||||
detail=f"File size {len(image_file)} bytes exceeds maximum of {self.MAX_FILE_SIZE} bytes",
|
||||
)
|
||||
return image_file
|
||||
|
||||
def log_error(self, e: Exception) -> None:
|
||||
curr_dir = Path(__file__).parent
|
||||
log_dir = curr_dir / "logs"
|
||||
log_dir.mkdir(exist_ok=True)
|
||||
log_file = f"{datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}.log"
|
||||
with open(log_dir / log_file, "w") as f:
|
||||
f.write(f"{type(e)}")
|
||||
f.write("\n\n")
|
||||
f.write(str(e))
|
||||
f.write("\n\n")
|
||||
f.write(traceback.format_exc())
|
||||
|
||||
Reference in New Issue
Block a user