internal 1.0.124__py3-none-any.whl → 1.0.126__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of internal might be problematic. Click here for more details.
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import time
|
|
3
3
|
|
|
4
|
+
from collections import defaultdict
|
|
4
5
|
from fastapi import FastAPI, Request
|
|
5
6
|
from starlette.middleware.base import BaseHTTPMiddleware
|
|
7
|
+
from ..const import CORRELATION_ID_HEADER_KEY_NAME
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
class LogRequestMiddleware(BaseHTTPMiddleware):
|
|
@@ -16,10 +18,16 @@ class LogRequestMiddleware(BaseHTTPMiddleware):
|
|
|
16
18
|
url = request.url.path
|
|
17
19
|
method = request.method
|
|
18
20
|
headers = request.headers
|
|
19
|
-
|
|
21
|
+
request_id = headers.get(CORRELATION_ID_HEADER_KEY_NAME, "")
|
|
22
|
+
|
|
23
|
+
params = defaultdict(list)
|
|
24
|
+
for key, value in request.query_params.multi_items():
|
|
25
|
+
params[key].append(value)
|
|
26
|
+
params = dict(params)
|
|
27
|
+
|
|
20
28
|
body = await request.body()
|
|
21
29
|
self.logger.info(
|
|
22
|
-
f"Method: {method}, URL: {url} - Headers: {headers} - Params: {params} - Body: {body} start processing...")
|
|
30
|
+
f"[Request id: {request_id}] Method: {method}, URL: {url} - Headers: {headers} - Params: {params} - Body: {body} start processing...")
|
|
23
31
|
|
|
24
32
|
# 记录请求处理时间
|
|
25
33
|
start_time = time.time()
|
|
@@ -27,5 +35,5 @@ class LogRequestMiddleware(BaseHTTPMiddleware):
|
|
|
27
35
|
process_time = time.time() - start_time
|
|
28
36
|
|
|
29
37
|
self.logger.info(
|
|
30
|
-
f"Method: {method}, URL: {url} - Headers: {headers} - Params: {params} - Body: {body}, Completed in {process_time:.4f} seconds")
|
|
38
|
+
f"[Request id: {request_id}] Method: {method}, URL: {url} - Headers: {headers} - Params: {params} - Body: {body}, Completed in {process_time:.4f} seconds")
|
|
31
39
|
return response
|
|
@@ -28,12 +28,12 @@ internal/http/responses.py,sha256=zvU0iRQ9-qxeEZfKmuvTi8lv9DFcaNAsHlQKOTCpVzw,29
|
|
|
28
28
|
internal/interface/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
29
29
|
internal/interface/base_interface.py,sha256=3YaVjIgLi_pZpLk5SEIk8WVkuICM8qPavT8rB0MdB5U,1536
|
|
30
30
|
internal/middleware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
31
|
-
internal/middleware/log_request.py,sha256=
|
|
31
|
+
internal/middleware/log_request.py,sha256=0_F3_d8dq59RbfDhp5bcht7T7pWVKabSaL6B4ATGfbw,1423
|
|
32
32
|
internal/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
33
33
|
internal/model/base_model.py,sha256=NWjysNOp2MfXvAHGFqaQA_l8ZfTFvJbXQPUPuOXN_2g,5361
|
|
34
34
|
internal/model/operate.py,sha256=QSM6yXYXpJMwrqkUGEWZLrEBaUgqHwVHY_Fi4S42hKc,3190
|
|
35
35
|
internal/utils.py,sha256=i6YZdiXsiWnOjRdlJ6afNCGpyMe3Uo9mhm3xlQBy3Ls,2824
|
|
36
36
|
internal/validator_utils.py,sha256=5ZLcNIgw1hvkYOj1f6gS9AYxe7Y3ufW9FyDxUS7FsMQ,1226
|
|
37
|
-
internal-1.0.
|
|
38
|
-
internal-1.0.
|
|
39
|
-
internal-1.0.
|
|
37
|
+
internal-1.0.126.dist-info/METADATA,sha256=POwa3uUDcB3hMtvADBFgUx_pI_EL82wO5GWsbXdbkwE,809
|
|
38
|
+
internal-1.0.126.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
|
|
39
|
+
internal-1.0.126.dist-info/RECORD,,
|
|
File without changes
|