sharedkernel 2.10.0__tar.gz → 2.11.0__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.
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/PKG-INFO +3 -1
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/README.md +2 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/setup.py +1 -1
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/logger/log_decorator.py +21 -2
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/logger/log_dto.py +1 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/logger/logger_service.py +12 -6
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel.egg-info/PKG-INFO +3 -1
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/setup.cfg +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/chunker/chunk_rule.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/chunker/text_chunker.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/common.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/config.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/data_format_converter.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/database/__init__.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/database/audit_model.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/database/cache/__init__.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/database/cache/cache_repository.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/database/cache/redis_generic_cache.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/database/distributed_cache.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/database/mongo_generic_audit_repository.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/database/mongo_generic_repository.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/database/mongo_health_checker.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/database/pagination_response_dto.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/date_converter.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/diff_utils.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/encryption_service.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/enum/__init__.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/enum/error_code.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/enum/feature_display_type.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/enum/feature_key.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/enum/order_type.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/enum/plan_interval.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/enum/plan_type.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/enum/redis_mode_enum.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/enum/sort_order.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/enum/user_role.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/exception/__init__.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/exception/exception.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/exception/exception_handlers.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/file_validation.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/ip_session_service.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/jwt_service.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/logger/log_enums.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/logger/log_info.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/logger/log_middlewares.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/multipart_upload.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/normalizer/__init__.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/normalizer/number_normalizer.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/normalizer/phone_number_normalizer.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/normalizer/string_normalizer.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/objects/__init__.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/objects/base_document.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/objects/json_string_model.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/objects/jwt_model.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/objects/result.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/objects/subscription.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/objects/user_info.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/objects/user_workspace.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/regex_masking.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/s3_uploader.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/string_extentions.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/toolbox_service.py +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel.egg-info/SOURCES.txt +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel.egg-info/dependency_links.txt +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel.egg-info/requires.txt +0 -0
- {sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sharedkernel
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.11.0
|
|
4
4
|
Summary: sharekernel is a shared package between all python projects
|
|
5
5
|
Author: Smilinno
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -33,6 +33,8 @@ Dynamic: summary
|
|
|
33
33
|
this is a shared kernel package
|
|
34
34
|
|
|
35
35
|
# Change Log
|
|
36
|
+
### Version 2.11.0
|
|
37
|
+
- Add router name to log service
|
|
36
38
|
### Version 2.10.0
|
|
37
39
|
- implement encryption service
|
|
38
40
|
### Version 2.9.5
|
|
@@ -44,7 +44,7 @@ setup(
|
|
|
44
44
|
"cryptography",
|
|
45
45
|
],
|
|
46
46
|
# *strongly* suggested for sharing
|
|
47
|
-
version="2.
|
|
47
|
+
version="2.11.0",
|
|
48
48
|
description="sharekernel is a shared package between all python projects",
|
|
49
49
|
long_description=long_description,
|
|
50
50
|
long_description_content_type="text/markdown",
|
|
@@ -2,6 +2,7 @@ import inspect
|
|
|
2
2
|
from functools import wraps
|
|
3
3
|
from typing import Callable, Type
|
|
4
4
|
from asyncio import iscoroutinefunction
|
|
5
|
+
from fastapi import Request
|
|
5
6
|
|
|
6
7
|
from sharedkernel.logger.logger_service import LoggerService
|
|
7
8
|
from sharedkernel import config
|
|
@@ -9,6 +10,22 @@ from sharedkernel import config
|
|
|
9
10
|
|
|
10
11
|
logger = LoggerService()
|
|
11
12
|
|
|
13
|
+
def get_router_name(args, kwargs) -> str | None:
|
|
14
|
+
request = next(
|
|
15
|
+
(
|
|
16
|
+
value
|
|
17
|
+
for value in (*args, *kwargs.values())
|
|
18
|
+
if isinstance(value, Request)
|
|
19
|
+
),
|
|
20
|
+
None,
|
|
21
|
+
)
|
|
22
|
+
if request is None:
|
|
23
|
+
return None
|
|
24
|
+
|
|
25
|
+
route = request.scope.get("route")
|
|
26
|
+
tags = getattr(route, "tags", None)
|
|
27
|
+
return tags[0] if tags else None
|
|
28
|
+
|
|
12
29
|
def decorate_class_methods(cls: Type) -> Type:
|
|
13
30
|
for name, attr in cls.__dict__.items():
|
|
14
31
|
if name.startswith("_"):
|
|
@@ -47,7 +64,8 @@ def unified_logger(endpoint_name: str = None, class_name: str = None) -> Callabl
|
|
|
47
64
|
|
|
48
65
|
@wraps(target)
|
|
49
66
|
async def async_wrapper(*args, **kwargs):
|
|
50
|
-
|
|
67
|
+
router_name = get_router_name(args, kwargs)
|
|
68
|
+
return await logger.execute_async(target, args, kwargs, method_name, endpoint_name, router_name=router_name)
|
|
51
69
|
|
|
52
70
|
return async_wrapper
|
|
53
71
|
|
|
@@ -55,7 +73,8 @@ def unified_logger(endpoint_name: str = None, class_name: str = None) -> Callabl
|
|
|
55
73
|
|
|
56
74
|
@wraps(target)
|
|
57
75
|
def sync_wrapper(*args, **kwargs):
|
|
58
|
-
|
|
76
|
+
router_name = get_router_name(args, kwargs)
|
|
77
|
+
return logger.execute_sync(target, args, kwargs, method_name, endpoint_name, router_name=router_name)
|
|
59
78
|
|
|
60
79
|
return sync_wrapper
|
|
61
80
|
|
|
@@ -10,6 +10,7 @@ class LogDTO(BaseModel):
|
|
|
10
10
|
EventType : Optional[LogEventTypeEnum] = None
|
|
11
11
|
Description: Optional[str] = None
|
|
12
12
|
MethodName: Optional[str] = None
|
|
13
|
+
RouterName: Optional[str] = None
|
|
13
14
|
IsSuccess : Optional[bool] = None
|
|
14
15
|
UserId : Optional[str] = None
|
|
15
16
|
UserName : Optional[str] = None
|
|
@@ -65,6 +65,7 @@ class LoggerService:
|
|
|
65
65
|
endpoint_name: Optional[str] = None,
|
|
66
66
|
is_success: Optional[bool] = True,
|
|
67
67
|
failure_reason: Optional[str] = None,
|
|
68
|
+
router_name: Optional[str] = None
|
|
68
69
|
) -> LogDTO:
|
|
69
70
|
|
|
70
71
|
log = log_info.get()
|
|
@@ -74,6 +75,7 @@ class LoggerService:
|
|
|
74
75
|
log.ServiceName = config.SERVICE_NAME
|
|
75
76
|
log.MethodName = method_name
|
|
76
77
|
log.Description = endpoint_name
|
|
78
|
+
log.RouterName = router_name
|
|
77
79
|
log.IsSuccess = is_success
|
|
78
80
|
log.Level = LogLevelEnum.INFORMATION if is_success else LogLevelEnum.ERROR
|
|
79
81
|
log.EventType = event_type
|
|
@@ -98,8 +100,8 @@ class LoggerService:
|
|
|
98
100
|
self.publish(log)
|
|
99
101
|
|
|
100
102
|
|
|
101
|
-
async def execute_async(self, target, args, kwargs, method_name, endpoint_name):
|
|
102
|
-
self.emit(self.build(method_name, LogEventTypeEnum.START, endpoint_name))
|
|
103
|
+
async def execute_async(self, target, args, kwargs, method_name, endpoint_name, router_name):
|
|
104
|
+
self.emit(self.build(method_name, LogEventTypeEnum.START, endpoint_name, router_name=router_name))
|
|
103
105
|
|
|
104
106
|
try:
|
|
105
107
|
result = await target(*args, **kwargs)
|
|
@@ -112,17 +114,18 @@ class LoggerService:
|
|
|
112
114
|
endpoint_name,
|
|
113
115
|
is_success=False,
|
|
114
116
|
failure_reason=self.map_exception(exc),
|
|
117
|
+
router_name=router_name
|
|
115
118
|
)
|
|
116
119
|
)
|
|
117
120
|
raise
|
|
118
121
|
|
|
119
122
|
else:
|
|
120
|
-
self.emit(self.build(method_name, LogEventTypeEnum.END, endpoint_name))
|
|
123
|
+
self.emit(self.build(method_name, LogEventTypeEnum.END, endpoint_name, router_name=router_name))
|
|
121
124
|
return result
|
|
122
125
|
|
|
123
126
|
|
|
124
|
-
def execute_sync(self, target, args, kwargs, method_name, endpoint_name):
|
|
125
|
-
self.emit(self.build(method_name, LogEventTypeEnum.START, endpoint_name))
|
|
127
|
+
def execute_sync(self, target, args, kwargs, method_name, endpoint_name, router_name):
|
|
128
|
+
self.emit(self.build(method_name, LogEventTypeEnum.START, endpoint_name, router_name=router_name))
|
|
126
129
|
|
|
127
130
|
try:
|
|
128
131
|
result = target(*args, **kwargs)
|
|
@@ -135,12 +138,13 @@ class LoggerService:
|
|
|
135
138
|
endpoint_name,
|
|
136
139
|
is_success=False,
|
|
137
140
|
failure_reason=self.map_exception(exc),
|
|
141
|
+
router_name=router_name
|
|
138
142
|
)
|
|
139
143
|
)
|
|
140
144
|
raise
|
|
141
145
|
|
|
142
146
|
else:
|
|
143
|
-
self.emit(self.build(method_name, LogEventTypeEnum.END, endpoint_name))
|
|
147
|
+
self.emit(self.build(method_name, LogEventTypeEnum.END, endpoint_name, router_name=router_name))
|
|
144
148
|
return result
|
|
145
149
|
|
|
146
150
|
@staticmethod
|
|
@@ -178,6 +182,7 @@ class LoggerService:
|
|
|
178
182
|
event_type=LogEventTypeEnum.START,
|
|
179
183
|
endpoint_name="اتصال به دیتابیس",
|
|
180
184
|
is_success=True,
|
|
185
|
+
router_name="مونگو"
|
|
181
186
|
)
|
|
182
187
|
self.emit(log)
|
|
183
188
|
|
|
@@ -188,6 +193,7 @@ class LoggerService:
|
|
|
188
193
|
event_type=LogEventTypeEnum.END,
|
|
189
194
|
endpoint_name="قطع اتصال به دیتابیس",
|
|
190
195
|
is_success=False,
|
|
196
|
+
router_name="مونگو",
|
|
191
197
|
)
|
|
192
198
|
self.emit(log)
|
|
193
199
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sharedkernel
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.11.0
|
|
4
4
|
Summary: sharekernel is a shared package between all python projects
|
|
5
5
|
Author: Smilinno
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -33,6 +33,8 @@ Dynamic: summary
|
|
|
33
33
|
this is a shared kernel package
|
|
34
34
|
|
|
35
35
|
# Change Log
|
|
36
|
+
### Version 2.11.0
|
|
37
|
+
- Add router name to log service
|
|
36
38
|
### Version 2.10.0
|
|
37
39
|
- implement encryption service
|
|
38
40
|
### Version 2.9.5
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/database/cache/redis_generic_cache.py
RENAMED
|
File without changes
|
|
File without changes
|
{sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/database/mongo_generic_audit_repository.py
RENAMED
|
File without changes
|
{sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/database/mongo_generic_repository.py
RENAMED
|
File without changes
|
|
File without changes
|
{sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/database/pagination_response_dto.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sharedkernel-2.10.0 → sharedkernel-2.11.0}/sharedkernel/normalizer/phone_number_normalizer.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|