Improve logging a bit

This commit is contained in:
2026-05-25 16:23:28 +02:00
parent 9160b312c7
commit 44ea17d87a
2 changed files with 35 additions and 22 deletions

View File

@@ -1,5 +1,6 @@
import logging
logger = logging.getLogger(__name__)
import os
from fastapi import FastAPI
from fastapi.security import OAuth2PasswordBearer
from contextlib import asynccontextmanager
@@ -14,10 +15,18 @@ oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
scanner = BackgroundScanner(db=get_db_session())
logging.basicConfig(level=logging.INFO)
def checkDeps():
load_dotenv()
MIFARE_APP_MASTER_KEY = os.getenv('MIFARE_APP_MASTER_KEY')
if not MIFARE_APP_MASTER_KEY:
logger.critical(f"MIFARE APP MASTER KEY not found!")
logger.critical("Writing and reading cards is disabled!")
global disableCards
disableCards = True
@asynccontextmanager
async def lifespan(app: FastAPI):
load_dotenv()
checkDeps()
create_db_and_tables()
create_first_user(db=get_db_session())
logger.info("Database created and tables initialized.")