Skip to content

Commit 3348c85

Browse files
committed
Pass logging config to uvicorn
1 parent 7b0c210 commit 3348c85

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/runners/uvicorn.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44

55
import uvicorn
66

7-
from log import get_logger, resolve_log_level
7+
from log import get_logger, resolve_log_level, setup_logging
88
from models.config import ServiceConfiguration
99

10-
logger = get_logger(__name__)
10+
logger = get_logger(__file__)
1111

1212

13-
def start_uvicorn(configuration: ServiceConfiguration) -> None:
13+
def start_uvicorn(
14+
configuration: ServiceConfiguration,
15+
log_config: dict | None = None,
16+
) -> None:
1417
"""Start the Uvicorn server using the provided service configuration.
1518
1619
Parameters:
@@ -22,6 +25,8 @@ def start_uvicorn(configuration: ServiceConfiguration) -> None:
2225
"""
2326
log_level = resolve_log_level()
2427
logger.info("Starting Uvicorn with log level %s", logging.getLevelName(log_level))
28+
if log_config is None:
29+
log_config = setup_logging()
2530

2631
# please note:
2732
# TLS fields can be None, which means we will pass those values as None to uvicorn.run
@@ -30,6 +35,7 @@ def start_uvicorn(configuration: ServiceConfiguration) -> None:
3035
host=configuration.host,
3136
port=configuration.port,
3237
workers=configuration.workers,
38+
log_config=log_config,
3339
log_level=log_level,
3440
ssl_keyfile=configuration.tls_config.tls_key_path,
3541
ssl_certfile=configuration.tls_config.tls_certificate_path,

0 commit comments

Comments
 (0)