Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-42689: Configure Uvicorn logging #132

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog.d/20240126_143234_rra_DM_42689.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### New features

- Configure Uvicorn to log accesses in a JSON format if datalinker is configured to use the production logging profile.
4 changes: 3 additions & 1 deletion src/datalinker/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from fastapi import FastAPI
from safir.dependencies.http_client import http_client_dependency
from safir.logging import configure_logging
from safir.logging import Profile, configure_logging, configure_uvicorn_logging
from safir.middleware.ivoa import CaseInsensitiveQueryMiddleware
from safir.middleware.x_forwarded import XForwardedMiddleware

Expand All @@ -36,6 +36,8 @@ async def lifespan(app: FastAPI) -> AsyncIterator[None]:
configure_logging(
profile=config.profile, log_level=config.log_level, name="datalinker"
)
if config.profile == Profile.production:
configure_uvicorn_logging(config.log_level)

app = FastAPI(
title="datalinker",
Expand Down
Loading