internal 1.1.39.1__py3-none-any.whl → 1.1.39.2__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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import json
|
|
1
2
|
import logging
|
|
2
3
|
import time
|
|
3
4
|
|
|
@@ -42,12 +43,48 @@ class LogRequestMiddleware(BaseHTTPMiddleware):
|
|
|
42
43
|
# 如果解碼失敗,顯示原始 bytes
|
|
43
44
|
body_str = str(body)
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
request_info = {
|
|
47
|
+
"request_id": request_id,
|
|
48
|
+
"method": method,
|
|
49
|
+
"url": url,
|
|
50
|
+
"params": params,
|
|
51
|
+
"body": body_str,
|
|
52
|
+
"content_type": content_type,
|
|
53
|
+
"user_agent": headers.get("user-agent", "")
|
|
54
|
+
}
|
|
55
|
+
self.logger.info(f"Request started: {json.dumps(request_info, ensure_ascii=False)}")
|
|
46
56
|
|
|
47
57
|
# 记录请求处理时间
|
|
48
58
|
start_time = time.time()
|
|
49
|
-
|
|
50
|
-
|
|
59
|
+
try:
|
|
60
|
+
response = await call_next(request)
|
|
61
|
+
process_time = time.time() - start_time
|
|
62
|
+
status_code = response.status_code
|
|
51
63
|
|
|
52
|
-
|
|
53
|
-
|
|
64
|
+
# 记录成功响应
|
|
65
|
+
response_info = {
|
|
66
|
+
"request_id": request_id,
|
|
67
|
+
"method": method,
|
|
68
|
+
"url": url,
|
|
69
|
+
"status_code": status_code,
|
|
70
|
+
"process_time": round(process_time, 4)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
self.logger.info(f"Request completed: {json.dumps(response_info, ensure_ascii=False)}")
|
|
74
|
+
|
|
75
|
+
return response
|
|
76
|
+
|
|
77
|
+
except Exception as e:
|
|
78
|
+
process_time = time.time() - start_time
|
|
79
|
+
|
|
80
|
+
# 记录异常
|
|
81
|
+
error_info = {
|
|
82
|
+
"request_id": request_id,
|
|
83
|
+
"method": method,
|
|
84
|
+
"url": url,
|
|
85
|
+
"error": str(e),
|
|
86
|
+
"process_time": round(process_time, 4)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
self.logger.error(f"Request failed: {json.dumps(error_info, ensure_ascii=False)}")
|
|
90
|
+
raise
|
|
@@ -29,12 +29,12 @@ internal/http/responses.py,sha256=75vJGS_aA9a5ff0HI6N03KM0CErIsAOtD06x7qr6yoQ,30
|
|
|
29
29
|
internal/interface/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
30
30
|
internal/interface/base_interface.py,sha256=3YaVjIgLi_pZpLk5SEIk8WVkuICM8qPavT8rB0MdB5U,1536
|
|
31
31
|
internal/middleware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
32
|
-
internal/middleware/log_request.py,sha256
|
|
32
|
+
internal/middleware/log_request.py,sha256=ZtCyfrF3IyKTF6Uj8L66CutdZi3srVmppqO_EXT5Tuw,3035
|
|
33
33
|
internal/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
34
34
|
internal/model/base_model.py,sha256=2M9EUWitzG-5FD4tYbUULBcWL6045HfS6OkpwzevmsY,7892
|
|
35
35
|
internal/model/operate.py,sha256=QSM6yXYXpJMwrqkUGEWZLrEBaUgqHwVHY_Fi4S42hKc,3190
|
|
36
36
|
internal/utils.py,sha256=wK1QumW1AaWE1ga2-WcDH2rtXRr2hSLwXzy-iI5dTzY,3962
|
|
37
37
|
internal/validator_utils.py,sha256=CqjaVFoAu5MqvBG_AkTP-r7AliWawtUWB851USj4moI,1519
|
|
38
|
-
internal-1.1.39.
|
|
39
|
-
internal-1.1.39.
|
|
40
|
-
internal-1.1.39.
|
|
38
|
+
internal-1.1.39.2.dist-info/METADATA,sha256=qm4E1RtqITZlQDcWyZPBWiwY4FULRZrgHjJg7KCzIvg,941
|
|
39
|
+
internal-1.1.39.2.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
|
|
40
|
+
internal-1.1.39.2.dist-info/RECORD,,
|
|
File without changes
|