Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rotating File Handler Log Config #33

Merged
merged 1 commit into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ cover/
*.pot

# Django stuff:
*.log
*.log*
local_settings.py
db.sqlite3
db.sqlite3-journal
Expand Down
3 changes: 0 additions & 3 deletions src/smolvault/clients/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)


Expand Down
8 changes: 6 additions & 2 deletions src/smolvault/main.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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=["*"],
Expand Down