python-sdk-local 0.0.24__py3-none-any.whl → 0.0.26__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.
- {python_sdk_local-0.0.24.dist-info → python_sdk_local-0.0.26.dist-info}/METADATA +1 -1
- python_sdk_local-0.0.26.dist-info/RECORD +12 -0
- sdk/src/LoggerOutputEnum.py +3 -3
- sdk/src/debug_mode.py +36 -20
- sdk/src/utilities.py +9 -21
- sdk/tests/debug_mode_test.py +74 -15
- python_sdk_local-0.0.24.dist-info/RECORD +0 -12
- {python_sdk_local-0.0.24.dist-info → python_sdk_local-0.0.26.dist-info}/WHEEL +0 -0
- {python_sdk_local-0.0.24.dist-info → python_sdk_local-0.0.26.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
sdk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
sdk/src/LoggerOutputEnum.py,sha256=tb7RzL3GpiRIStGtrncFmZ1N4zHM26dhygAW-GxYW9M,244
|
|
3
|
+
sdk/src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
sdk/src/debug_mode.py,sha256=uC_Lb5D5aMJZ8HWRRiAaPWO5wPkYB52Hk2LWLIAVy9k,3398
|
|
5
|
+
sdk/src/utilities.py,sha256=anOYgkOWd5rWcULERT5YsXgwTI7GmoBuk_ylX46WPGY,2227
|
|
6
|
+
sdk/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
sdk/tests/debug_mode_test.py,sha256=yDnlUU0bFgwGtzEf4GWoD2elJWTfdeWbU3TMxcSueuo,5803
|
|
8
|
+
sdk/tests/utilities_test.py,sha256=_LHRhaZWAKXhtcQN1MwSJq2AqpSC0W3n3sQpzwUtKlc,1857
|
|
9
|
+
python_sdk_local-0.0.26.dist-info/METADATA,sha256=k-wwDMGhWzojYwfC3X9b8MuwP16DiuLrHDPf0I3De9c,468
|
|
10
|
+
python_sdk_local-0.0.26.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
11
|
+
python_sdk_local-0.0.26.dist-info/top_level.txt,sha256=JuXS55gRP3EzGKmJgbLfVfUolO3cM_u69k3qvutnBuw,4
|
|
12
|
+
python_sdk_local-0.0.26.dist-info/RECORD,,
|
sdk/src/LoggerOutputEnum.py
CHANGED
sdk/src/debug_mode.py
CHANGED
|
@@ -5,18 +5,14 @@ from dotenv import load_dotenv
|
|
|
5
5
|
load_dotenv()
|
|
6
6
|
from logger_local.LoggerComponentEnum import LoggerComponentEnum
|
|
7
7
|
from logger_local.Logger import Logger
|
|
8
|
+
from logger_local.MessageSeverity import MessageSeverity
|
|
8
9
|
sys.path.append(os.getcwd())
|
|
9
10
|
from python_sdk_local.sdk.src.LoggerOutputEnum import LoggerOutputEnum
|
|
10
11
|
|
|
11
|
-
PYTHON_SDK_LOCAL_COMPONENT_ID =
|
|
12
|
+
PYTHON_SDK_LOCAL_COMPONENT_ID = 202
|
|
12
13
|
PYTHON_SDK_LOCAL_COMPONENT_NAME = 'python_sdk_local/src/debug_mode.py'
|
|
13
14
|
LOGGER_CONFIGURATION_JSON = '.logger.json'
|
|
14
|
-
LOGGER_MINIMUM_SEVERITY = os.getenv('LOGGER_MINIMUM_SEVERITY')
|
|
15
|
-
|
|
16
|
-
if not LOGGER_MINIMUM_SEVERITY:
|
|
17
|
-
LOGGER_MINIMUM_SEVERITY = 0
|
|
18
|
-
else:
|
|
19
|
-
LOGGER_MINIMUM_SEVERITY = int(LOGGER_MINIMUM_SEVERITY)
|
|
15
|
+
LOGGER_MINIMUM_SEVERITY = os.getenv('LOGGER_MINIMUM_SEVERITY')
|
|
20
16
|
|
|
21
17
|
|
|
22
18
|
obj = {
|
|
@@ -30,37 +26,57 @@ logger = Logger.create_logger(object=obj)
|
|
|
30
26
|
class DebugMode:
|
|
31
27
|
def __init__(self):
|
|
32
28
|
self.logger_json = {}
|
|
29
|
+
self.debug_everything = False
|
|
33
30
|
self._init()
|
|
34
31
|
|
|
35
32
|
def _init(self):
|
|
36
33
|
INIT_METHOD_NAME = "_init()"
|
|
37
34
|
logger.start(INIT_METHOD_NAME)
|
|
38
35
|
|
|
36
|
+
global LOGGER_MINIMUM_SEVERITY
|
|
37
|
+
if not LOGGER_MINIMUM_SEVERITY:
|
|
38
|
+
LOGGER_MINIMUM_SEVERITY = 0
|
|
39
|
+
else:
|
|
40
|
+
if hasattr(MessageSeverity, LOGGER_MINIMUM_SEVERITY):
|
|
41
|
+
LOGGER_MINIMUM_SEVERITY = MessageSeverity[LOGGER_MINIMUM_SEVERITY].value
|
|
42
|
+
elif LOGGER_MINIMUM_SEVERITY.isdigit():
|
|
43
|
+
LOGGER_MINIMUM_SEVERITY = int(LOGGER_MINIMUM_SEVERITY)
|
|
44
|
+
else:
|
|
45
|
+
raise Exception("LOGGER_MINIMUM_SEVERITY must be a valid LoggerOutputEnum or a number or None")
|
|
46
|
+
|
|
39
47
|
try:
|
|
40
48
|
with open(LOGGER_CONFIGURATION_JSON, 'r') as file:
|
|
41
49
|
self.logger_json = json.load(file)
|
|
42
|
-
except
|
|
43
|
-
|
|
50
|
+
except FileNotFoundError:
|
|
51
|
+
self.debug_everything = True
|
|
52
|
+
logger.info("could not find .logger.json file, debugging everything")
|
|
53
|
+
except Exception as exception:
|
|
54
|
+
logger.exception("encounteredthe following error", object={'exception': exception})
|
|
44
55
|
logger.end(INIT_METHOD_NAME)
|
|
45
|
-
|
|
46
|
-
|
|
56
|
+
raise
|
|
47
57
|
logger.end(INIT_METHOD_NAME)
|
|
48
58
|
|
|
49
|
-
def
|
|
59
|
+
def is_logger_output(self, component_id:str, logger_output: LoggerOutputEnum, severity_level:int)->bool:
|
|
60
|
+
IS_LOGGER_OUTPUT_METHOD_NAME = "is_logger_output()"
|
|
61
|
+
logger.start(IS_LOGGER_OUTPUT_METHOD_NAME, object={'component_id': component_id, 'logger_output': str(logger_output), 'severity_level': severity_level})
|
|
50
62
|
|
|
51
|
-
severity_level = max(severity_level, LOGGER_MINIMUM_SEVERITY)
|
|
52
|
-
|
|
53
|
-
FETCH_METHOD_NAME = "fetch()"
|
|
54
|
-
logger.start(FETCH_METHOD_NAME, object={'component_id': component_id, 'logger_output': str(logger_output), 'severity_level': severity_level})
|
|
55
63
|
|
|
64
|
+
#Debug everything that has a severity level higher than the minimum required
|
|
65
|
+
if self.debug_everything:
|
|
66
|
+
result = severity_level >= LOGGER_MINIMUM_SEVERITY
|
|
67
|
+
logger.end(IS_LOGGER_OUTPUT_METHOD_NAME, object={'result': result})
|
|
68
|
+
return result
|
|
69
|
+
|
|
70
|
+
severity_level = max(severity_level, LOGGER_MINIMUM_SEVERITY)
|
|
56
71
|
if component_id in self.logger_json:
|
|
57
72
|
output_info = self.logger_json[component_id]
|
|
58
73
|
if logger_output in output_info:
|
|
59
74
|
result = severity_level >= output_info[logger_output]
|
|
60
|
-
logger.end(
|
|
75
|
+
logger.end(IS_LOGGER_OUTPUT_METHOD_NAME, object={'result': result})
|
|
61
76
|
return result
|
|
62
|
-
|
|
63
77
|
|
|
64
|
-
|
|
65
|
-
|
|
78
|
+
# In case the component do not exist in the logger configuration file or the
|
|
79
|
+
# logger_output was not specif
|
|
80
|
+
result = True
|
|
81
|
+
logger.end(IS_LOGGER_OUTPUT_METHOD_NAME, object={'result': result})
|
|
66
82
|
return result
|
sdk/src/utilities.py
CHANGED
|
@@ -41,26 +41,14 @@ def is_list_of_dicts(obj):
|
|
|
41
41
|
IS_LIST_OF_DICTS_FUNCTION_NAME = "is_list_of_dicts()"
|
|
42
42
|
logger.start(IS_LIST_OF_DICTS_FUNCTION_NAME,object = {"obj":obj})
|
|
43
43
|
if not isinstance(obj, list):
|
|
44
|
-
|
|
45
|
-
logger.end(IS_LIST_OF_DICTS_FUNCTION_NAME,object = {"
|
|
46
|
-
return
|
|
44
|
+
is_list_of_dicts_result = False
|
|
45
|
+
logger.end(IS_LIST_OF_DICTS_FUNCTION_NAME,object = {"is_list_of_dicts_result": is_list_of_dicts_result})
|
|
46
|
+
return is_list_of_dicts_result
|
|
47
47
|
for item in obj:
|
|
48
48
|
if not isinstance(item, dict):
|
|
49
|
-
|
|
50
|
-
logger.end(IS_LIST_OF_DICTS_FUNCTION_NAME,object = {'
|
|
51
|
-
return
|
|
52
|
-
|
|
53
|
-
logger.end(IS_LIST_OF_DICTS_FUNCTION_NAME,object = {'
|
|
54
|
-
return
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
# componet id
|
|
61
|
-
# sevirity
|
|
62
|
-
# output
|
|
63
|
-
#minimum sevirity
|
|
64
|
-
|
|
65
|
-
# init from debug file
|
|
66
|
-
# get from
|
|
49
|
+
is_list_of_dicts_result = False
|
|
50
|
+
logger.end(IS_LIST_OF_DICTS_FUNCTION_NAME,object = {'is_list_of_dicts_result': is_list_of_dicts_result})
|
|
51
|
+
return is_list_of_dicts_result
|
|
52
|
+
is_list_of_dicts_result = True
|
|
53
|
+
logger.end(IS_LIST_OF_DICTS_FUNCTION_NAME,object = {'is_list_of_dicts_result': is_list_of_dicts_result})
|
|
54
|
+
return is_list_of_dicts_result
|
sdk/tests/debug_mode_test.py
CHANGED
|
@@ -67,10 +67,10 @@ def test_debug_mode_init():
|
|
|
67
67
|
assert result
|
|
68
68
|
|
|
69
69
|
|
|
70
|
-
def
|
|
70
|
+
def test_is_logger_output_debug_info_1():
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
logger.start(
|
|
72
|
+
TEST_is_logger_output_DEBUG_INFO_1_FUNCTION_NAME = 'test_is_logger_output_debug_info_1()'
|
|
73
|
+
logger.start(TEST_is_logger_output_DEBUG_INFO_1_FUNCTION_NAME)
|
|
74
74
|
|
|
75
75
|
add_debug_file(EXAMPLE_DATA_1)
|
|
76
76
|
|
|
@@ -78,17 +78,17 @@ def test_fetch_debug_info_1():
|
|
|
78
78
|
|
|
79
79
|
remove_debug_file()
|
|
80
80
|
|
|
81
|
-
result = debug.
|
|
82
|
-
logger.end(
|
|
81
|
+
result = debug.is_logger_output('1', LoggerOutputEnum.Console.value, 501) == True
|
|
82
|
+
logger.end(TEST_is_logger_output_DEBUG_INFO_1_FUNCTION_NAME,
|
|
83
83
|
object={'result': result})
|
|
84
84
|
|
|
85
85
|
assert result
|
|
86
86
|
|
|
87
87
|
|
|
88
|
-
def
|
|
88
|
+
def test_is_logger_output_debug_mode_2():
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
logger.start(
|
|
90
|
+
TEST_is_logger_output_DEBUG_MODE_2_FUNCTION_NAME = 'test_is_logger_output_debug_mode_2()'
|
|
91
|
+
logger.start(TEST_is_logger_output_DEBUG_MODE_2_FUNCTION_NAME)
|
|
92
92
|
|
|
93
93
|
add_debug_file(EXAMPLE_DATA_2)
|
|
94
94
|
|
|
@@ -96,12 +96,12 @@ def test_fetch_debug_mode_2():
|
|
|
96
96
|
|
|
97
97
|
remove_debug_file()
|
|
98
98
|
|
|
99
|
-
result1 = debug.
|
|
100
|
-
result2 = debug.
|
|
101
|
-
result3 = debug.
|
|
99
|
+
result1 = debug.is_logger_output('2', LoggerOutputEnum.Logzio.value, 502) == True
|
|
100
|
+
result2 = debug.is_logger_output('2', LoggerOutputEnum.MySQLDatabase.value, 503) == True
|
|
101
|
+
result3 = debug.is_logger_output('2', LoggerOutputEnum.Console.value, 499) == False
|
|
102
102
|
|
|
103
103
|
result = result1 and result2 and result3
|
|
104
|
-
logger.end(
|
|
104
|
+
logger.end(TEST_is_logger_output_DEBUG_MODE_2_FUNCTION_NAME,
|
|
105
105
|
object={'result': result})
|
|
106
106
|
assert result
|
|
107
107
|
|
|
@@ -117,15 +117,74 @@ def test_minimum_sevirity():
|
|
|
117
117
|
|
|
118
118
|
remove_debug_file()
|
|
119
119
|
|
|
120
|
-
result1 = debug.
|
|
121
|
-
result2 = debug.
|
|
120
|
+
result1 = debug.is_logger_output('2', LoggerOutputEnum.Logzio.value, 501) == False
|
|
121
|
+
result2 = debug.is_logger_output('2', LoggerOutputEnum.Logzio.value, 502) == True
|
|
122
122
|
|
|
123
123
|
debug_mode.LOGGER_MINIMUM_SEVERITY = 0
|
|
124
124
|
|
|
125
125
|
result = result1 and result2
|
|
126
126
|
logger.end(TEST_MINIMUM_SEVIRITY_FUNCTION_NAME, object={'result': result})
|
|
127
127
|
assert result
|
|
128
|
+
|
|
129
|
+
def test_debug_everything():
|
|
128
130
|
|
|
131
|
+
TEST_DEBUG_EVERYTHING_FUNCTION_NAME = 'test_debug_everything()'
|
|
132
|
+
logger.start(TEST_DEBUG_EVERYTHING_FUNCTION_NAME)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
debug = debug_mode.DebugMode() # file DNE, so debug_everything = True
|
|
136
|
+
|
|
137
|
+
result1 = debug.is_logger_output('2', LoggerOutputEnum.Logzio.value, 501) == True
|
|
138
|
+
result2 = debug.is_logger_output('2', LoggerOutputEnum.Logzio.value, 502) == True
|
|
139
|
+
|
|
140
|
+
debug_mode.LOGGER_MINIMUM_SEVERITY = 0
|
|
141
|
+
|
|
142
|
+
result = result1 and result2
|
|
143
|
+
logger.end(TEST_DEBUG_EVERYTHING_FUNCTION_NAME, object={'result': result})
|
|
144
|
+
assert result
|
|
145
|
+
|
|
146
|
+
def test_invalid_logger_minimum_sevirity():
|
|
147
|
+
|
|
148
|
+
TEST_INVALID_LOGGER_MINIMUM_SEVIRITY_FUNCTION_NAME = 'test_invalid_logger_minimum_sevirity()'
|
|
149
|
+
logger.start(TEST_INVALID_LOGGER_MINIMUM_SEVIRITY_FUNCTION_NAME)
|
|
129
150
|
|
|
151
|
+
debug_mode.LOGGER_MINIMUM_SEVERITY = 'invalid'
|
|
152
|
+
|
|
153
|
+
try:
|
|
154
|
+
debug = debug_mode.DebugMode()
|
|
155
|
+
except Exception as e:
|
|
156
|
+
result = True
|
|
157
|
+
else:
|
|
158
|
+
result = False
|
|
159
|
+
|
|
160
|
+
logger.end(TEST_INVALID_LOGGER_MINIMUM_SEVIRITY_FUNCTION_NAME, object={'result': result})
|
|
161
|
+
assert result
|
|
162
|
+
|
|
163
|
+
def test_alpha_numeric_minimum_severity():
|
|
164
|
+
|
|
165
|
+
TEST_ALPHA_NUMERIC_MINIMUM_SEVERITY_FUNCTION_NAME = 'test_alpha_numeric_minimum_severity()'
|
|
166
|
+
logger.start(TEST_ALPHA_NUMERIC_MINIMUM_SEVERITY_FUNCTION_NAME)
|
|
167
|
+
|
|
168
|
+
debug_mode.LOGGER_MINIMUM_SEVERITY = '13'
|
|
169
|
+
|
|
170
|
+
debug = debug_mode.DebugMode()
|
|
171
|
+
|
|
172
|
+
result =debug_mode.LOGGER_MINIMUM_SEVERITY = 13
|
|
173
|
+
|
|
174
|
+
logger.end(TEST_ALPHA_NUMERIC_MINIMUM_SEVERITY_FUNCTION_NAME, object={'result': result})
|
|
175
|
+
assert result
|
|
176
|
+
|
|
177
|
+
def test_enum_minimal_severity():
|
|
178
|
+
TEST_ENUM_MINIMAL_SEVERITY_FUNCTION_NAME = 'test_enum_minimal_severity()'
|
|
179
|
+
logger.start(TEST_ENUM_MINIMAL_SEVERITY_FUNCTION_NAME)
|
|
180
|
+
|
|
181
|
+
debug_mode.LOGGER_MINIMUM_SEVERITY = 'Information'
|
|
182
|
+
|
|
183
|
+
debug = debug_mode.DebugMode()
|
|
184
|
+
|
|
185
|
+
result =debug_mode.LOGGER_MINIMUM_SEVERITY == 500
|
|
186
|
+
|
|
187
|
+
logger.end(TEST_ENUM_MINIMAL_SEVERITY_FUNCTION_NAME, object={'result': result})
|
|
188
|
+
assert result
|
|
130
189
|
|
|
131
|
-
|
|
190
|
+
test_debug_everything()
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
sdk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
sdk/src/LoggerOutputEnum.py,sha256=KvYYBHTEWe85AR9l0F9uvZPbuJ1uTo-4jv3mYxlNnD8,242
|
|
3
|
-
sdk/src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
sdk/src/debug_mode.py,sha256=7BheicjABZfceT4b0MGf8njhWY1qAi0lG8PJCtQ3tAk,2253
|
|
5
|
-
sdk/src/utilities.py,sha256=VcwlskviysA5bP5Z3REQtjN6eh_GxVPZeZviVrqgG-I,2117
|
|
6
|
-
sdk/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
sdk/tests/debug_mode_test.py,sha256=VeWRcUUBeW4zTMNLHzoHB28PLBBaMoIrGYq_OzS1IBw,3616
|
|
8
|
-
sdk/tests/utilities_test.py,sha256=_LHRhaZWAKXhtcQN1MwSJq2AqpSC0W3n3sQpzwUtKlc,1857
|
|
9
|
-
python_sdk_local-0.0.24.dist-info/METADATA,sha256=dE8o7JxJQQONXozyR_cknedjFqgtrGh7pnxxNDLLUHs,468
|
|
10
|
-
python_sdk_local-0.0.24.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
11
|
-
python_sdk_local-0.0.24.dist-info/top_level.txt,sha256=JuXS55gRP3EzGKmJgbLfVfUolO3cM_u69k3qvutnBuw,4
|
|
12
|
-
python_sdk_local-0.0.24.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|