Improve logging a bit
This commit is contained in:
11
app/main.py
11
app/main.py
@@ -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.")
|
||||
|
||||
Reference in New Issue
Block a user