mirror of
https://github.com/Viren070/MediaFusion.git
synced 2025-12-01 23:21:11 +01:00
078635a172
Update configurations and logging Refactor IMDB movie retrieval Update deployment settings Remove unused deployment Update resource limits for dramatiq worker
24 lines
783 B
Python
24 lines
783 B
Python
import logging
|
|
|
|
from fastapi.requests import Request
|
|
from fastapi.responses import Response
|
|
|
|
|
|
class SecureLoggingMiddleware:
|
|
async def __call__(self, request: Request, call_next):
|
|
response = await call_next(request)
|
|
self.custom_log(request, response)
|
|
return response
|
|
|
|
@staticmethod
|
|
def custom_log(request: Request, response: Response):
|
|
client_host = request.client.host if request.client else "unknown"
|
|
url_path = str(request.url)
|
|
if request.path_params.get("secret_str"):
|
|
url_path = url_path.replace(
|
|
request.path_params.get("secret_str"), "***MASKED***"
|
|
)
|
|
logging.info(
|
|
f'{client_host} - "{request.method} {url_path} HTTP/1.1" {response.status_code}'
|
|
)
|