logger-36 2024.22__py3-none-any.whl → 2024.23__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.
- logger_36/constant/message.py +1 -1
- logger_36/task/format/message.py +24 -14
- logger_36/type/issue.py +2 -0
- logger_36/type/logger.py +27 -2
- logger_36/version.py +1 -1
- {logger_36-2024.22.dist-info → logger_36-2024.23.dist-info}/METADATA +1 -1
- {logger_36-2024.22.dist-info → logger_36-2024.23.dist-info}/RECORD +9 -9
- {logger_36-2024.22.dist-info → logger_36-2024.23.dist-info}/WHEEL +0 -0
- {logger_36-2024.22.dist-info → logger_36-2024.23.dist-info}/top_level.txt +0 -0
logger_36/constant/message.py
CHANGED
@@ -19,7 +19,7 @@ LOG_LEVEL_LENGTH = 1 + LEVEL_OPENING.__len__() + LEVEL_CLOSING.__len__()
|
|
19
19
|
CONTEXT_LENGTH = TIME_LENGTH + LOG_LEVEL_LENGTH
|
20
20
|
NEXT_LINE_PROLOGUE = "\n" + (CONTEXT_LENGTH + MESSAGE_MARKER.__len__() + 1) * " "
|
21
21
|
|
22
|
-
expected_op_h = h.Literal[": ", "=", "!=", ">=", "<="]
|
22
|
+
expected_op_h = h.Literal[":", ": ", "=", "!=", ">=", "<="]
|
23
23
|
EXPECTED_OP: tuple[str, ...] = h.get_args(expected_op_h)
|
24
24
|
|
25
25
|
"""
|
logger_36/task/format/message.py
CHANGED
@@ -4,6 +4,7 @@ Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
|
4
4
|
SEE COPYRIGHT NOTICE BELOW
|
5
5
|
"""
|
6
6
|
|
7
|
+
import difflib as diff
|
7
8
|
import typing as h
|
8
9
|
|
9
10
|
from logger_36.config.message import (
|
@@ -40,6 +41,7 @@ def FormattedMessage(
|
|
40
41
|
*,
|
41
42
|
actual: h.Any = NOT_PASSED,
|
42
43
|
expected: h.Any | None = None,
|
44
|
+
expected_is_choices: bool = False,
|
43
45
|
expected_op: expected_op_h = "=",
|
44
46
|
with_final_dot: bool = True,
|
45
47
|
) -> str:
|
@@ -64,27 +66,35 @@ def FormattedMessage(
|
|
64
66
|
|
65
67
|
if message[-1] == ".":
|
66
68
|
message = message[:-1]
|
67
|
-
|
68
|
-
expected = _FormattedValue(expected)
|
69
|
-
|
69
|
+
expected = _FormattedExpected(expected_op, expected, expected_is_choices, actual)
|
70
70
|
if with_final_dot:
|
71
71
|
dot = "."
|
72
72
|
else:
|
73
73
|
dot = ""
|
74
|
-
return f"{message}: Actual={actual}; Expected{expected_op}{expected}{dot}"
|
75
|
-
|
76
74
|
|
77
|
-
|
78
|
-
""""""
|
79
|
-
if value is None:
|
80
|
-
return "None"
|
75
|
+
return f"{message}: Actual={actual}:{type(actual).__name__}; {expected}{dot}"
|
81
76
|
|
82
|
-
if isinstance(value, str):
|
83
|
-
if should_format_str:
|
84
|
-
return f'"{value}"'
|
85
|
-
return value
|
86
77
|
|
87
|
-
|
78
|
+
def _FormattedExpected(
|
79
|
+
operator: str, expected: h.Any, expected_is_choices: bool, actual: h.Any, /
|
80
|
+
) -> str:
|
81
|
+
""""""
|
82
|
+
if isinstance(expected, h.Sequence) and expected_is_choices:
|
83
|
+
close_matches = diff.get_close_matches(actual, expected)
|
84
|
+
if close_matches.__len__() > 0:
|
85
|
+
close_matches = ", ".join(close_matches)
|
86
|
+
return f"Close matche(s): {close_matches}"
|
87
|
+
else:
|
88
|
+
expected = ", ".join(map(str, expected))
|
89
|
+
return f"Valid values: {expected}"
|
90
|
+
else:
|
91
|
+
if operator == "=":
|
92
|
+
stripe = f":{type(expected).__name__}"
|
93
|
+
else:
|
94
|
+
stripe = ""
|
95
|
+
if operator == ":":
|
96
|
+
operator = ": "
|
97
|
+
return f"Expected{operator}{expected}{stripe}"
|
88
98
|
|
89
99
|
|
90
100
|
"""
|
logger_36/type/issue.py
CHANGED
@@ -25,6 +25,7 @@ def NewIssue(
|
|
25
25
|
level: int = lggg.ERROR,
|
26
26
|
actual: h.Any = NOT_PASSED,
|
27
27
|
expected: h.Any | None = None,
|
28
|
+
expected_is_choices: bool = False,
|
28
29
|
expected_op: expected_op_h = "=",
|
29
30
|
with_final_dot: bool = True,
|
30
31
|
) -> issue_t:
|
@@ -35,6 +36,7 @@ def NewIssue(
|
|
35
36
|
message,
|
36
37
|
actual=actual,
|
37
38
|
expected=expected,
|
39
|
+
expected_is_choices=expected_is_choices,
|
38
40
|
expected_op=expected_op,
|
39
41
|
with_final_dot=with_final_dot,
|
40
42
|
)
|
logger_36/type/logger.py
CHANGED
@@ -221,7 +221,30 @@ class logger_t(lggg.Logger):
|
|
221
221
|
# __post_init__ set self.exit_on_critical if self.exit_on_error.
|
222
222
|
sstm.exit(1)
|
223
223
|
|
224
|
-
def
|
224
|
+
def Log(
|
225
|
+
self,
|
226
|
+
message: str,
|
227
|
+
/,
|
228
|
+
*,
|
229
|
+
level: int = lggg.ERROR,
|
230
|
+
actual: h.Any = NOT_PASSED,
|
231
|
+
expected: h.Any | None = None,
|
232
|
+
expected_is_choices: bool = False,
|
233
|
+
expected_op: expected_op_h = "=",
|
234
|
+
with_final_dot: bool = True,
|
235
|
+
) -> None:
|
236
|
+
""""""
|
237
|
+
message = FormattedMessage(
|
238
|
+
message,
|
239
|
+
actual=actual,
|
240
|
+
expected=expected,
|
241
|
+
expected_is_choices=expected_is_choices,
|
242
|
+
expected_op=expected_op,
|
243
|
+
with_final_dot=with_final_dot,
|
244
|
+
)
|
245
|
+
self.log(level, message)
|
246
|
+
|
247
|
+
def LogException(
|
225
248
|
self,
|
226
249
|
exception: Exception,
|
227
250
|
/,
|
@@ -236,7 +259,7 @@ class logger_t(lggg.Logger):
|
|
236
259
|
else:
|
237
260
|
# TODO: Explain:
|
238
261
|
# - Why it's not: "\n".join(lines)?
|
239
|
-
# - Why adding
|
262
|
+
# - Why adding exception name here and not when removing caller?
|
240
263
|
formatted = "".join(lines)
|
241
264
|
message = f"{type(exception).__name__}:\n{formatted}"
|
242
265
|
self.log(level, message)
|
@@ -262,6 +285,7 @@ class logger_t(lggg.Logger):
|
|
262
285
|
level: int = lggg.ERROR,
|
263
286
|
actual: h.Any = NOT_PASSED,
|
264
287
|
expected: h.Any | None = None,
|
288
|
+
expected_is_choices: bool = False,
|
265
289
|
expected_op: expected_op_h = "=",
|
266
290
|
with_final_dot: bool = False,
|
267
291
|
) -> None:
|
@@ -274,6 +298,7 @@ class logger_t(lggg.Logger):
|
|
274
298
|
level=level,
|
275
299
|
actual=actual,
|
276
300
|
expected=expected,
|
301
|
+
expected_is_choices=expected_is_choices,
|
277
302
|
expected_op=expected_op,
|
278
303
|
with_final_dot=with_final_dot,
|
279
304
|
)
|
logger_36/version.py
CHANGED
@@ -5,7 +5,7 @@ logger_36/logger.py,sha256=7LJtdT7TmfFsn6r34iTr6OGvEjXlU6hKXEO2c5Lm2zY,2386
|
|
5
5
|
logger_36/logger_gpu.py,sha256=YYFk6aYQrBDJfxQaDm-ar16T6SlOSL6jJWTOgvpF4EU,2244
|
6
6
|
logger_36/measure.py,sha256=P507VNbVKAf4jYGnGX-3rlDrVbrYP0ZD3nxFmAFvhyI,2404
|
7
7
|
logger_36/storage.py,sha256=O8pDmiL0B3LJpKrhi8a9IMBXs6MwW6r1bMUn_cSDAaY,2246
|
8
|
-
logger_36/version.py,sha256=
|
8
|
+
logger_36/version.py,sha256=4_FGnjQh_s8oYEhxb9KRp7Q6xpIM8ntNmNoRxRRQqfo,2206
|
9
9
|
logger_36/catalog/config/console_rich.py,sha256=QDkgSs3I7ZULvkd1q4J1hdvgyB857JJcJWxM9fdL51Y,2883
|
10
10
|
logger_36/catalog/handler/console.py,sha256=SF9S3CUoEPp5dh7RrqotywDJjMgRp0rD9sO3eLVXnkA,4004
|
11
11
|
logger_36/catalog/handler/console_rich.py,sha256=Ti1k2E1ox4egzicghTb9Wv30xiWaBbWwe8ouopJsujY,8792
|
@@ -26,7 +26,7 @@ logger_36/constant/handler.py,sha256=HM8qCSEMGNMCzddjUUNBPGL-3d0qU-EmG5eW4ZQHW6A
|
|
26
26
|
logger_36/constant/issue.py,sha256=01l8itRPWGS5F6gXtsXUJgGR-4lS1Eu3_YeKC-khKLw,2315
|
27
27
|
logger_36/constant/logger.py,sha256=0GhemAQ_YBiRO5WQBuNTczuejyVu2IYCsgqPRIbL8es,2780
|
28
28
|
logger_36/constant/memory.py,sha256=ZL1MwbdtNsrCrOwzEyfTsfOoOsRBTJtbbf3otHGnxXo,2343
|
29
|
-
logger_36/constant/message.py,sha256=
|
29
|
+
logger_36/constant/message.py,sha256=JMnCmW4j-oa-Cs1iZCJ5yAG6V4BzjLCGRIvEw6pQTtU,2719
|
30
30
|
logger_36/constant/record.py,sha256=zebZYR4buX1lGfc7IyuvEh8zOpk7hx0aS4pJ12H0flI,2311
|
31
31
|
logger_36/constant/system.py,sha256=G2mzBTxRXoJMxb53TnmBaceMJC_q3WonoCG7y6nC_R8,2430
|
32
32
|
logger_36/instance/logger.py,sha256=ttKjl9MD7FUjqCWjv5w2hmmpDYxgaORcYf9NaaE9W_M,2246
|
@@ -34,15 +34,15 @@ logger_36/instance/loggers.py,sha256=RCWpC1NPAf6vXnFc9NqsSALv-x-FEzcH6k_OlxTxeQk
|
|
34
34
|
logger_36/task/inspection.py,sha256=f9VkVrwMJ_ixV9rFu3XUNpmCbEgoo1tssqd2nMeGYLI,5028
|
35
35
|
logger_36/task/storage.py,sha256=XaSeu-iBCa0N8HNpwCV7cLprj-lbOJocpTIKUgSOvsc,5668
|
36
36
|
logger_36/task/format/memory.py,sha256=ECOdHjdxIqXivOwtcmwpLDMYUrutIeOTCn1L4d3-U8k,4241
|
37
|
-
logger_36/task/format/message.py,sha256=
|
37
|
+
logger_36/task/format/message.py,sha256=CP1E8tNY1hkc_dujrxTV2DW2iGopx4ew4xV_HgwOlDw,4705
|
38
38
|
logger_36/task/format/rule.py,sha256=YEe8wG_QLy9vRZqmT2bWlvKT-Dxp4pGaZVmEuwwODyE,2598
|
39
39
|
logger_36/task/measure/chronos.py,sha256=t-y0bVm1SmF-3wI9pR9Bp6-qzVlsE94fZTZr5a_hZUA,2884
|
40
40
|
logger_36/task/measure/memory.py,sha256=eVw5WOYLyn8o4O4mMArdX2MzsVuhhNDovjYEkk-MIaU,2504
|
41
41
|
logger_36/type/handler.py,sha256=BXpevZhLq5V_IdUfi_LZA4czzlH2SGLpgvbqUBe5X10,8311
|
42
|
-
logger_36/type/issue.py,sha256=
|
43
|
-
logger_36/type/logger.py,sha256=
|
42
|
+
logger_36/type/issue.py,sha256=Y7OCLCzVt6Yvkecwj8HXLdZjg33oMxexc9XkYHzUhh4,3202
|
43
|
+
logger_36/type/logger.py,sha256=1PNs4sGZM7JvIMuveU-2X4TL9CbrIm7WSHq54SjSpRw,16653
|
44
44
|
logger_36/type/loggers.py,sha256=znqxWBnfQxvkg3VUfbTUvt3S6Kq0DAzWWepxQDt9suI,2871
|
45
|
-
logger_36-2024.
|
46
|
-
logger_36-2024.
|
47
|
-
logger_36-2024.
|
48
|
-
logger_36-2024.
|
45
|
+
logger_36-2024.23.dist-info/METADATA,sha256=ycisLVTVoTOgt6tPDkBqwhEUSZhCVtqmEM_MAl6vEMQ,6276
|
46
|
+
logger_36-2024.23.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
|
47
|
+
logger_36-2024.23.dist-info/top_level.txt,sha256=sM95BTMWmslEEgR_1pzwZsOeSp8C_QBiu8ImbFr0XLc,10
|
48
|
+
logger_36-2024.23.dist-info/RECORD,,
|
File without changes
|
File without changes
|