-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
27 lines (22 loc) · 874 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import logging
from uvicorn import Config, Server
from viaa.configuration import ConfigParser
cfg_log_level = ConfigParser().chassis_cfg["logging"]["level"]
# Uvicorn expects lowercase string or integer as the logging level.
LOG_LEVEL = cfg_log_level.lower() if isinstance(cfg_log_level, str) else cfg_log_level
if __name__ == "__main__":
server = Server(
Config(
"app.app:app",
host="0.0.0.0",
port=8080,
access_log=False,
log_level=LOG_LEVEL,
),
)
# Remove the Uvicorn logging handlers, as our own loggers log in a JSON format.
# Just remove them all although the access handler is already removed by "access_log=False".
for name, logger in logging.root.manager.loggerDict.items():
if name.startswith("uvicorn"):
logger.handlers = []
server.run()