api: simplify logging setup
This commit is contained in:
parent
7ac0a4106c
commit
b1b624a7b3
2 changed files with 7 additions and 6 deletions
|
|
@ -1,4 +1,6 @@
|
|||
import os
|
||||
import sys
|
||||
import logging
|
||||
from contextvars import ContextVar
|
||||
from argparse import ArgumentParser, Namespace
|
||||
|
||||
|
|
@ -72,6 +74,10 @@ def main():
|
|||
)
|
||||
args = argp.parse_args()
|
||||
|
||||
# setup logging
|
||||
logging.basicConfig(level=logging.DEBUG, format="[%(levelname)s] %(filename)s: %(message)s")
|
||||
|
||||
# setup app
|
||||
app_config.set(args)
|
||||
import uvicorn
|
||||
from dooris_api.app import app
|
||||
|
|
@ -80,6 +86,7 @@ def main():
|
|||
from fastapi.staticfiles import StaticFiles
|
||||
app.mount("/", StaticFiles(directory=args.serve_static, html=True), name="static")
|
||||
|
||||
# start webserver
|
||||
config = uvicorn.Config(app, port=8000, log_level="debug")
|
||||
server = uvicorn.Server(config)
|
||||
server.run()
|
||||
|
|
|
|||
|
|
@ -22,12 +22,6 @@ logger = logging.getLogger(__name__)
|
|||
async def lifespan(app: FastAPI):
|
||||
app_cfg = app_config.get()
|
||||
|
||||
root_logger = logging.getLogger("")
|
||||
root_logger.setLevel(logging.INFO)
|
||||
root_logger.addHandler(logging.StreamHandler(sys.stderr))
|
||||
app_logger = logging.getLogger("dooris_api")
|
||||
app_logger.setLevel(logging.DEBUG)
|
||||
|
||||
app.extra["oidc_client"] = OpenidClient.from_issuer_url(
|
||||
url=app_cfg.openid_issuer,
|
||||
authentication_redirect_uri=f"{app_cfg.base_url}/auth/login-callback",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue