Skip to content

Commit 0631674

Browse files
committed
add some docs
1 parent 3ec8bc7 commit 0631674

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/service-library/src/servicelib/fastapi/logging_lifespan.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def setup_logging_lifespan(
2424
log_base_level: LogLevelInt,
2525
noisy_loggers: tuple[str, ...] | None,
2626
) -> Lifespan:
27+
"""Returns a FastAPI-compatible lifespan handler to set up async logging."""
2728
exit_stack = AsyncExitStack()
2829
exit_stack.enter_context(
2930
setup_async_loggers_lifespan(
@@ -52,6 +53,13 @@ def setup_logging_shutdown_event(
5253
log_base_level: LogLevelInt,
5354
noisy_loggers: tuple[str, ...] | None,
5455
) -> Callable[[], Awaitable[None]]:
56+
"""retruns a fastapi-compatible shutdown event handler to be used with old style lifespan
57+
handlers. This is useful for applications that do not use the new async lifespan
58+
handlers introduced in fastapi 0.100.0.
59+
60+
Note: This function is for backwards compatibility only and will be removed in the future.
61+
setup_logging_lifespan should be used instead for new style lifespan handlers.
62+
"""
5563
exit_stack = AsyncExitStack()
5664
exit_stack.enter_context(
5765
setup_async_loggers_lifespan(

0 commit comments

Comments
 (0)