mirror of
https://github.com/fastapi-practices/fastapi_best_architecture.git
synced 2025-08-14 19:04:00 +08:00

* Update the log output default style * Update the log file compression * fix line * Add log summary
16 lines
382 B
Python
16 lines
382 B
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
from fastapi import Request
|
|
|
|
from backend.core.conf import settings
|
|
|
|
|
|
def get_request_trace_id(request: Request) -> str:
|
|
"""
|
|
从请求头中获取追踪 ID
|
|
|
|
:param request: FastAPI 请求对象
|
|
:return:
|
|
"""
|
|
return request.headers.get(settings.TRACE_ID_REQUEST_HEADER_KEY) or settings.TRACE_ID_LOG_DEFAULT_VALUE
|