diff --git a/.gitignore b/.gitignore index aff1e46..7355966 100644 --- a/.gitignore +++ b/.gitignore @@ -56,7 +56,7 @@ cover/ *.pot # Django stuff: -*.log +*.log* local_settings.py db.sqlite3 db.sqlite3-journal diff --git a/src/smolvault/clients/aws.py b/src/smolvault/clients/aws.py index 11f2f5c..48d7404 100644 --- a/src/smolvault/clients/aws.py +++ b/src/smolvault/clients/aws.py @@ -6,9 +6,6 @@ from smolvault.config import get_settings from smolvault.models import FileUploadDTO -logging.basicConfig( - level=logging.INFO, filename="app.log", filemode="a", format="%(asctime)s - %(levelname)s - %(message)s" -) logger = logging.getLogger(__name__) diff --git a/src/smolvault/main.py b/src/smolvault/main.py index fa30725..abf00dc 100644 --- a/src/smolvault/main.py +++ b/src/smolvault/main.py @@ -1,7 +1,9 @@ import json import logging import os +import sys import urllib.parse +from logging.handlers import RotatingFileHandler from typing import Annotated from fastapi import Depends, FastAPI, File, Form, UploadFile @@ -15,11 +17,13 @@ from smolvault.models import FileMetadata, FileTagsDTO, FileUploadDTO logging.basicConfig( - level=logging.INFO, filename="app.log", filemode="a", format="%(asctime)s - %(levelname)s - %(message)s" + handlers=[RotatingFileHandler("app.log", maxBytes=100_000, backupCount=10), logging.StreamHandler(sys.stdout)], + level=logging.INFO, + format="%(asctime)s [%(processName)s: %(process)d] [%(threadName)s: %(thread)d] [%(levelname)s] %(name)s: %(message)s", ) logger = logging.getLogger(__name__) -app = FastAPI(debug=True) +app = FastAPI(title="smolvault") app.add_middleware( CORSMiddleware, allow_origins=["*"],