diff --git a/.gitignore b/.gitignore index e51a0fd..807854f 100644 --- a/.gitignore +++ b/.gitignore @@ -149,4 +149,5 @@ secrets.* .idea/ # Logs +logs/ *.log diff --git a/app/main.py b/app/main.py index aa923a4..69dc459 100644 --- a/app/main.py +++ b/app/main.py @@ -10,6 +10,20 @@ from app.models import Base import os import json +import logging + +# Handle the logging +log_directory = "logs" +if not os.path.exists(log_directory): + os.makedirs(log_directory) +log_file_path = os.path.join(log_directory, "app.log") + +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(levelname)s - %(message)s', + handlers=[logging.StreamHandler(), logging.FileHandler('logs/app.log')] +) +logging.info("FastAPI application started.") # Create database tables only if not in test environment if not os.getenv("TESTING"): diff --git a/env.example b/env.example index 46c3942..491f47e 100644 --- a/env.example +++ b/env.example @@ -31,4 +31,5 @@ AWS_S3_BUCKET=aixiv-papers # ======================================== SECRET_KEY=your_secret_key_here DEBUG=True -ALLOWED_ORIGINS=http://localhost:3000,http://127.0.0.1:3000 \ No newline at end of file +ALLOWED_ORIGINS=http://localhost:3000,http://127.0.0.1:3000 +AUTH_TOKEN=your-auth-token-here \ No newline at end of file