internal 1.0.6__tar.gz → 1.0.8__tar.gz

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.

Files changed (31) hide show
  1. {internal-1.0.6 → internal-1.0.8}/PKG-INFO +1 -1
  2. {internal-1.0.6 → internal-1.0.8}/pyproject.toml +1 -1
  3. {internal-1.0.6 → internal-1.0.8}/src/internal/base_config.py +2 -0
  4. {internal-1.0.6 → internal-1.0.8}/src/internal/base_factory.py +4 -0
  5. internal-1.0.8/src/internal/middleware/log_request.py +25 -0
  6. internal-1.0.8/src/internal/model/__init__.py +0 -0
  7. {internal-1.0.6 → internal-1.0.8}/src/internal/model/base_model.py +1 -1
  8. {internal-1.0.6 → internal-1.0.8}/README.md +0 -0
  9. {internal-1.0.6 → internal-1.0.8}/src/internal/__init__.py +0 -0
  10. {internal-1.0.6 → internal-1.0.8}/src/internal/common_enum/__init__.py +0 -0
  11. {internal-1.0.6 → internal-1.0.8}/src/internal/common_enum/contact_type.py +0 -0
  12. {internal-1.0.6 → internal-1.0.8}/src/internal/common_enum/event_type.py +0 -0
  13. {internal-1.0.6 → internal-1.0.8}/src/internal/common_enum/operator_type.py +0 -0
  14. {internal-1.0.6 → internal-1.0.8}/src/internal/common_enum/service_ticket_event_trigger_type.py +0 -0
  15. {internal-1.0.6 → internal-1.0.8}/src/internal/const.py +0 -0
  16. {internal-1.0.6 → internal-1.0.8}/src/internal/database.py +0 -0
  17. {internal-1.0.6 → internal-1.0.8}/src/internal/exception/__init__.py +0 -0
  18. {internal-1.0.6 → internal-1.0.8}/src/internal/exception/base_exception.py +0 -0
  19. {internal-1.0.6 → internal-1.0.8}/src/internal/exception/internal_exception.py +0 -0
  20. {internal-1.0.6 → internal-1.0.8}/src/internal/ext/__init__.py +0 -0
  21. {internal-1.0.6 → internal-1.0.8}/src/internal/ext/amazon/__init__.py +0 -0
  22. {internal-1.0.6 → internal-1.0.8}/src/internal/ext/amazon/aws/__init__.py +0 -0
  23. {internal-1.0.6 → internal-1.0.8}/src/internal/ext/amazon/aws/const.py +0 -0
  24. {internal-1.0.6 → internal-1.0.8}/src/internal/http/__init__.py +0 -0
  25. {internal-1.0.6 → internal-1.0.8}/src/internal/http/requests.py +0 -0
  26. {internal-1.0.6 → internal-1.0.8}/src/internal/http/responses.py +0 -0
  27. {internal-1.0.6 → internal-1.0.8}/src/internal/interface/__init__.py +0 -0
  28. {internal-1.0.6 → internal-1.0.8}/src/internal/interface/base_interface.py +0 -0
  29. {internal-1.0.6/src/internal/model → internal-1.0.8/src/internal/middleware}/__init__.py +0 -0
  30. {internal-1.0.6 → internal-1.0.8}/src/internal/model/operate.py +0 -0
  31. {internal-1.0.6 → internal-1.0.8}/src/internal/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: internal
3
- Version: 1.0.6
3
+ Version: 1.0.8
4
4
  Summary:
5
5
  Author: Ray
6
6
  Author-email: ray@cruisys.com
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "internal"
3
- version = "1.0.6"
3
+ version = "1.0.8"
4
4
  description = ""
5
5
  authors = ["Ray <ray@cruisys.com>"]
6
6
  readme = "README.md"
@@ -8,6 +8,8 @@ class BaseConfig(BaseSettings):
8
8
 
9
9
  OPEN_API_URL: str = "/openapi.json"
10
10
 
11
+ LOGGER_REQUEST_ENABLE: bool = True
12
+
11
13
  # Request
12
14
  REQUEST_VERIFY_SSL: bool = True
13
15
  REQUEST_PROXY: str = ''
@@ -18,6 +18,7 @@ from .exception.base_exception import InternalBaseException
18
18
  from .ext.amazon import aws
19
19
  from .http.requests import async_request
20
20
  from .http.responses import async_response
21
+ from .middleware.log_request import LogRequestMiddleware
21
22
  from .utils import update_dict_with_cast
22
23
 
23
24
 
@@ -68,6 +69,9 @@ class BaseFactory(metaclass=ABCMeta):
68
69
  self.__setup_cloud_log(app)
69
70
  self.__load_cloud_config(app)
70
71
 
72
+ if self.get_app_config().LOGGER_REQUEST_ENABLE:
73
+ app.add_middleware(LogRequestMiddleware)
74
+
71
75
  mongodb = database.MongoDB(self.get_app_config().DATABASE_USERNAME, self.get_app_config().DATABASE_PASSWORD,
72
76
  self.get_app_config().DATABASE_HOST, self.get_app_config().DATABASE_PORT,
73
77
  self.get_app_config().DATABASE_NAME,
@@ -0,0 +1,25 @@
1
+ import time
2
+
3
+ from fastapi import FastAPI, Request
4
+ from starlette.middleware.base import BaseHTTPMiddleware
5
+
6
+
7
+ class LogRequestMiddleware(BaseHTTPMiddleware):
8
+ def __init__(self, app: FastAPI):
9
+ super().__init__(app)
10
+ self.app = app
11
+
12
+ async def dispatch(self, request: Request, call_next):
13
+ # 记录请求的URL和参数
14
+ url = request.url.path
15
+ params = dict(request.query_params)
16
+ body = await request.body()
17
+ self.app.state.logger.info(f"URL: {url} - Params: {params} - Body: {body}")
18
+
19
+ # 记录请求处理时间
20
+ start_time = time.time()
21
+ response = await call_next(request)
22
+ process_time = time.time() - start_time
23
+
24
+ self.app.state.logger.info(f"Completed in {process_time:.4f} seconds")
25
+ return response
File without changes
@@ -50,7 +50,7 @@ class InternalBaseDocument(Document):
50
50
 
51
51
  return page_no, page_size, total_num, page_data
52
52
 
53
- async def update_wrap(self, schema: Union[Dict, Type[BaseModel]]) -> Tuple[Operate, 'InternalBaseDocument']:
53
+ async def update_wrap(self, schema: Union[Dict, Type[BaseModel]]) -> Tuple[Operate, 'InternalBaseDocument', 'InternalBaseDocument']:
54
54
  if not issubclass(type(schema), dict) and not issubclass(type(schema), BaseModel):
55
55
  raise TypeError("Schema must be a subclass of BaseModel or dict")
56
56
 
File without changes
File without changes
File without changes