Add configurable logging from settings
This commit is contained in:
parent
435c11b6ca
commit
e925f21762
3 changed files with 14 additions and 0 deletions
|
@ -6,6 +6,9 @@ from typing import Annotated
|
|||
from pathlib import Path
|
||||
from datetime import datetime
|
||||
import logging
|
||||
import logging.config
|
||||
import importlib.resources
|
||||
from yaml import safe_load
|
||||
from urllib.parse import urlencode
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
|
@ -46,6 +49,16 @@ from oidc_test.resource_server import resource_server
|
|||
|
||||
logger = logging.getLogger("oidc-test")
|
||||
|
||||
if settings.log:
|
||||
assert __package__ is not None
|
||||
with (
|
||||
importlib.resources.path(__package__) as package_path,
|
||||
open(package_path / settings.log_config_file) as f,
|
||||
):
|
||||
logging_config = safe_load(f)
|
||||
logging.config.dictConfig(logging_config)
|
||||
|
||||
breakpoint()
|
||||
templates = Jinja2Templates(Path(__file__).parent / "templates")
|
||||
|
||||
|
||||
|
|
|
@ -104,6 +104,7 @@ class Settings(BaseSettings):
|
|||
auth: AuthSettings = AuthSettings()
|
||||
secret_key: str = "".join(random.choice(string.ascii_letters) for _ in range(16))
|
||||
log: bool = False
|
||||
log_config_file: str = "log_conf.yaml"
|
||||
insecure: Insecure = Insecure()
|
||||
cors_origins: list[str] = []
|
||||
debug_token: bool = False
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue