internal 1.0.8__py3-none-any.whl → 1.0.9__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.

internal/base_factory.py CHANGED
@@ -70,7 +70,7 @@ class BaseFactory(metaclass=ABCMeta):
70
70
  self.__load_cloud_config(app)
71
71
 
72
72
  if self.get_app_config().LOGGER_REQUEST_ENABLE:
73
- app.add_middleware(LogRequestMiddleware)
73
+ app.add_middleware(LogRequestMiddleware, logger=self.state.logger)
74
74
 
75
75
  mongodb = database.MongoDB(self.get_app_config().DATABASE_USERNAME, self.get_app_config().DATABASE_PASSWORD,
76
76
  self.get_app_config().DATABASE_HOST, self.get_app_config().DATABASE_PORT,
@@ -1,3 +1,4 @@
1
+ import logging
1
2
  import time
2
3
 
3
4
  from fastapi import FastAPI, Request
@@ -5,21 +6,22 @@ from starlette.middleware.base import BaseHTTPMiddleware
5
6
 
6
7
 
7
8
  class LogRequestMiddleware(BaseHTTPMiddleware):
8
- def __init__(self, app: FastAPI):
9
+ def __init__(self, app: FastAPI, logger: logging.Logger):
9
10
  super().__init__(app)
10
11
  self.app = app
12
+ self.logger = logger
11
13
 
12
14
  async def dispatch(self, request: Request, call_next):
13
15
  # 记录请求的URL和参数
14
16
  url = request.url.path
15
17
  params = dict(request.query_params)
16
18
  body = await request.body()
17
- self.app.state.logger.info(f"URL: {url} - Params: {params} - Body: {body}")
19
+ self.logger.info(f"URL: {url} - Params: {params} - Body: {body}")
18
20
 
19
21
  # 记录请求处理时间
20
22
  start_time = time.time()
21
23
  response = await call_next(request)
22
24
  process_time = time.time() - start_time
23
25
 
24
- self.app.state.logger.info(f"Completed in {process_time:.4f} seconds")
26
+ self.logger.info(f"Completed in {process_time:.4f} seconds")
25
27
  return response
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: internal
3
- Version: 1.0.8
3
+ Version: 1.0.9
4
4
  Summary:
5
5
  Author: Ray
6
6
  Author-email: ray@cruisys.com
@@ -1,6 +1,6 @@
1
1
  internal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  internal/base_config.py,sha256=5-s2muyaLOGKhrq8kVqq0qaXFD09FrcQZCAFmw1FQtk,1755
3
- internal/base_factory.py,sha256=VkRrmCZOuwFriezqhsX5RziuzRSoJvsH6Wn3QD5sBHs,7829
3
+ internal/base_factory.py,sha256=KtqCeyCNlEzcw4oe-AC9UMwidl6LigbspD0ZNSrlAuY,7855
4
4
  internal/common_enum/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  internal/common_enum/contact_type.py,sha256=uwZjxImXltMmfoAbe-1IeK3ry-p_wJ-wPPWR6NB7WXM,142
6
6
  internal/common_enum/event_type.py,sha256=jMuqiVGhOcYaJ7rYpn-nSpVH08bUsycF7ezHqpXk_Mc,114
@@ -21,11 +21,11 @@ internal/http/responses.py,sha256=b3Qc-iQmoYyFYrFv_lCQKbMNUu6My53YRRbUMn_1QoI,16
21
21
  internal/interface/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
22
  internal/interface/base_interface.py,sha256=R5MmO5oa5-ORPV_adkegLVCwsVio2zFOuQFGiby3khs,340
23
23
  internal/middleware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
- internal/middleware/log_request.py,sha256=Zdv5qyJ5F1meQ7tyni7i1GEOKtd03F1vIVlxObrSKUU,806
24
+ internal/middleware/log_request.py,sha256=bXAxmvvsYDhObXzfUw4ZNreKAWOo8ee_vpb6Xin5ztc,854
25
25
  internal/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
26
  internal/model/base_model.py,sha256=svULVdROpcnmTyhIbZ7M6pn40vhb_qIZ5W2CEyuEWZE,3002
27
27
  internal/model/operate.py,sha256=luEoP_Asvso_11qz1SAE1Kn5KxAnDRptM0VylC5tNik,1493
28
28
  internal/utils.py,sha256=0SubS0iUhDvjSX1F4TykasA5-enYJzt2VH-f7_0BnjI,1509
29
- internal-1.0.8.dist-info/METADATA,sha256=G7l5s22lLmbQxgKpScnyEBgQkG3aZ_IDixpWsZobvK4,624
30
- internal-1.0.8.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
31
- internal-1.0.8.dist-info/RECORD,,
29
+ internal-1.0.9.dist-info/METADATA,sha256=NDFoiFWuYxUq76ZMMqqb843vMfNkO84tjAyR3UEmWj4,624
30
+ internal-1.0.9.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
31
+ internal-1.0.9.dist-info/RECORD,,