logger-36 2024.10__py3-none-any.whl → 2024.12__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/catalog/config/console_rich.py +4 -1
- logger_36/catalog/handler/generic.py +6 -1
- logger_36/config/message.py +0 -2
- logger_36/constant/memory.py +2 -0
- logger_36/type/extension.py +15 -1
- logger_36/type/logger.py +31 -17
- logger_36/version.py +1 -1
- {logger_36-2024.10.dist-info → logger_36-2024.12.dist-info}/METADATA +2 -2
- {logger_36-2024.10.dist-info → logger_36-2024.12.dist-info}/RECORD +11 -11
- {logger_36-2024.10.dist-info → logger_36-2024.12.dist-info}/WHEEL +0 -0
- {logger_36-2024.10.dist-info → logger_36-2024.12.dist-info}/top_level.txt +0 -0
@@ -29,6 +29,9 @@
|
|
29
29
|
# The fact that you are presently reading this means that you have had
|
30
30
|
# knowledge of the CeCILL license and that you accept its terms.
|
31
31
|
|
32
|
+
"""
|
33
|
+
Colors: See https://rich.readthedocs.io/en/stable/appendix/colors.html.
|
34
|
+
"""
|
32
35
|
import logging as lggg
|
33
36
|
|
34
37
|
from rich.color import Color as color_t
|
@@ -42,7 +45,7 @@ LEVEL_COLOR: dict[int, str | style_t] = {
|
|
42
45
|
lggg.ERROR: "orange1",
|
43
46
|
lggg.CRITICAL: "red",
|
44
47
|
}
|
45
|
-
ACTUAL_COLOR: str = "
|
48
|
+
ACTUAL_COLOR: str = "indian_red"
|
46
49
|
EXPECTED_COLOR: str = "green"
|
47
50
|
ELAPSED_TIME_COLOR: str = "green"
|
48
51
|
|
@@ -37,6 +37,7 @@ from logger_36.catalog.config.console_rich import DATE_TIME_COLOR
|
|
37
37
|
|
38
38
|
try:
|
39
39
|
from rich.console import Console as console_t
|
40
|
+
from rich.console import ConsoleOptions as console_options_t
|
40
41
|
from rich.markup import escape as EscapedForRich
|
41
42
|
from rich.terminal_theme import DEFAULT_TERMINAL_THEME
|
42
43
|
except ModuleNotFoundError:
|
@@ -60,6 +61,7 @@ class generic_handler_t(lggg.Handler):
|
|
60
61
|
|
61
62
|
extension: handler_extension_t = dtcl.field(init=False)
|
62
63
|
console: console_t | None = None
|
64
|
+
console_options: console_options_t | None = None
|
63
65
|
FormattedLines: h.Callable[..., tuple[str, str | None]] = dtcl.field(init=False)
|
64
66
|
ShowMessage: h.Callable[[str], None] = lambda _arg: None
|
65
67
|
|
@@ -104,6 +106,9 @@ class generic_handler_t(lggg.Handler):
|
|
104
106
|
force_terminal=True,
|
105
107
|
**rich_kwargs,
|
106
108
|
)
|
109
|
+
self.console_options = self.console.options.update(
|
110
|
+
overflow="ignore", no_wrap=True
|
111
|
+
)
|
107
112
|
|
108
113
|
self.FormattedLines = self.extension.FormattedLines
|
109
114
|
|
@@ -126,7 +131,7 @@ class generic_handler_t(lggg.Handler):
|
|
126
131
|
richer = console_rich_handler_t.HighlightedVersion(
|
127
132
|
first, next_s, record.levelno
|
128
133
|
)
|
129
|
-
segments = self.console.render(richer)
|
134
|
+
segments = self.console.render(richer, options=self.console_options)
|
130
135
|
|
131
136
|
# Inspired from the code of: rich.console.export_html.
|
132
137
|
html_segments = []
|
logger_36/config/message.py
CHANGED
logger_36/constant/memory.py
CHANGED
logger_36/type/extension.py
CHANGED
@@ -33,6 +33,8 @@ import dataclasses as dtcl
|
|
33
33
|
import logging as lggg
|
34
34
|
import sys as sstm
|
35
35
|
import typing as h
|
36
|
+
from os import sep as FOLDER_SEPARATOR
|
37
|
+
from pathlib import Path as path_t
|
36
38
|
|
37
39
|
from logger_36.config.message import TIME_FORMAT, WHERE_FORMAT
|
38
40
|
from logger_36.constant.error import MEMORY_MEASURE_ERROR
|
@@ -123,8 +125,20 @@ class handler_extension_t:
|
|
123
125
|
if hide_where:
|
124
126
|
record.where = ""
|
125
127
|
else:
|
128
|
+
module = path_t(record.pathname)
|
129
|
+
path_was_found = False
|
130
|
+
for path in sstm.path:
|
131
|
+
if module.is_relative_to(path):
|
132
|
+
module = module.relative_to(path)
|
133
|
+
path_was_found = True
|
134
|
+
break
|
135
|
+
if path_was_found:
|
136
|
+
module = str(module.parent / module.stem)
|
137
|
+
module = module.replace(FOLDER_SEPARATOR, ".")
|
138
|
+
else:
|
139
|
+
module = record.module
|
126
140
|
record.where = WHERE_FORMAT.format(
|
127
|
-
module=
|
141
|
+
module=module, funcName=record.funcName, lineno=record.lineno
|
128
142
|
)
|
129
143
|
first_line = self.FormattedRecord(record).replace("\t", " ")
|
130
144
|
|
logger_36/type/logger.py
CHANGED
@@ -42,7 +42,7 @@ from pathlib import Path as path_t
|
|
42
42
|
from traceback import TracebackException as traceback_t
|
43
43
|
|
44
44
|
from logger_36.config.issue import ISSUE_CONTEXT_END, ISSUE_CONTEXT_SEPARATOR
|
45
|
-
from logger_36.config.message import DATE_FORMAT
|
45
|
+
from logger_36.config.message import DATE_FORMAT
|
46
46
|
from logger_36.constant.generic import NOT_PASSED
|
47
47
|
from logger_36.constant.issue import ORDER, order_h
|
48
48
|
from logger_36.constant.logger import (
|
@@ -52,6 +52,7 @@ from logger_36.constant.logger import (
|
|
52
52
|
WARNING_TYPE_COMPILED_PATTERN,
|
53
53
|
logger_handle_h,
|
54
54
|
)
|
55
|
+
from logger_36.constant.memory import UNKNOWN_MEMORY_USAGE
|
55
56
|
from logger_36.constant.record import SHOW_MEMORY_ATTR, SHOW_W_RULE_ATTR
|
56
57
|
from logger_36.task.format.memory import (
|
57
58
|
FormattedUsageWithAutoUnit as FormattedMemoryUsage,
|
@@ -103,7 +104,6 @@ class logger_t(lggg.Logger):
|
|
103
104
|
"""
|
104
105
|
if self.intercepted_wrn_handle is None:
|
105
106
|
logger = lggg.getLogger(WARNING_LOGGER_NAME)
|
106
|
-
|
107
107
|
self.intercepted_wrn_handle = logger.handle
|
108
108
|
logger.handle = t.MethodType(_HandleForWarnings(self), logger)
|
109
109
|
|
@@ -114,7 +114,6 @@ class logger_t(lggg.Logger):
|
|
114
114
|
""""""
|
115
115
|
if self.intercepted_wrn_handle is not None:
|
116
116
|
logger = lggg.getLogger(WARNING_LOGGER_NAME)
|
117
|
-
|
118
117
|
logger.handle = self.intercepted_wrn_handle
|
119
118
|
self.intercepted_wrn_handle = None
|
120
119
|
|
@@ -146,8 +145,9 @@ class logger_t(lggg.Logger):
|
|
146
145
|
|
147
146
|
intercepted = sorted(self.intercepted_log_handles.keys())
|
148
147
|
if intercepted.__len__() > 0:
|
148
|
+
as_str = ", ".join(intercepted)
|
149
149
|
self.info(
|
150
|
-
f"Now Intercepting LOGs from: {
|
150
|
+
f"Now Intercepting LOGs from: {as_str}",
|
151
151
|
**HIDE_WHERE_KWARG,
|
152
152
|
)
|
153
153
|
elif self.intercepted_log_handles.__len__() > 0:
|
@@ -160,15 +160,20 @@ class logger_t(lggg.Logger):
|
|
160
160
|
@property
|
161
161
|
def max_memory_usage(self) -> int:
|
162
162
|
""""""
|
163
|
-
|
163
|
+
if self.memory_usages.__len__() > 0:
|
164
|
+
return max(tuple(zip(*self.memory_usages))[1])
|
165
|
+
return UNKNOWN_MEMORY_USAGE
|
164
166
|
|
165
167
|
@property
|
166
168
|
def max_memory_usage_full(self) -> tuple[str, int]:
|
167
169
|
""""""
|
168
|
-
|
169
|
-
|
170
|
+
if self.memory_usages.__len__() > 0:
|
171
|
+
where_s, usages = zip(*self.memory_usages)
|
172
|
+
max_usage = max(usages)
|
170
173
|
|
171
|
-
|
174
|
+
return where_s[usages.index(max_usage)], max_usage
|
175
|
+
|
176
|
+
return "?", UNKNOWN_MEMORY_USAGE
|
172
177
|
|
173
178
|
def AddHandler(self, handler: lggg.Handler, should_hold_messages: bool, /) -> None:
|
174
179
|
""""""
|
@@ -309,7 +314,7 @@ class logger_t(lggg.Logger):
|
|
309
314
|
print("\n".join(lines), file=sstm.stderr)
|
310
315
|
sstm.exit(1)
|
311
316
|
|
312
|
-
self.log(level, issues,
|
317
|
+
self.log(level, issues, stacklevel=2)
|
313
318
|
self.staged_issues.clear()
|
314
319
|
|
315
320
|
def __enter__(self) -> None:
|
@@ -332,16 +337,25 @@ def _HandleForWarnings(interceptor: lggg.Logger, /) -> logger_handle_h:
|
|
332
337
|
""""""
|
333
338
|
|
334
339
|
def handle_p(_: lggg.Logger, record: lggg.LogRecord, /) -> None:
|
335
|
-
pieces = WARNING_TYPE_COMPILED_PATTERN.match(record.msg)
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
+
pieces = WARNING_TYPE_COMPILED_PATTERN.match(record.msg)
|
341
|
+
if pieces is None:
|
342
|
+
# The warning message does not follow the default format.
|
343
|
+
interceptor.handle(record)
|
344
|
+
return
|
345
|
+
|
346
|
+
GetPiece = pieces.group
|
347
|
+
path = GetPiece(1)
|
348
|
+
line = GetPiece(2)
|
349
|
+
kind = GetPiece(3)
|
350
|
+
message = GetPiece(4)
|
351
|
+
|
340
352
|
duplicate = lggg.makeLogRecord(record.__dict__)
|
341
353
|
duplicate.msg = f"{kind}: {message}"
|
342
|
-
duplicate.
|
343
|
-
duplicate.
|
354
|
+
duplicate.pathname = path
|
355
|
+
duplicate.module = path_t(path).stem
|
356
|
+
duplicate.funcName = "?"
|
344
357
|
duplicate.lineno = line
|
358
|
+
|
345
359
|
interceptor.handle(duplicate)
|
346
360
|
|
347
361
|
return handle_p
|
@@ -354,7 +368,7 @@ def _HandleForInterceptions(
|
|
354
368
|
|
355
369
|
def handle_p(_: lggg.Logger, record: lggg.LogRecord, /) -> None:
|
356
370
|
duplicate = lggg.makeLogRecord(record.__dict__)
|
357
|
-
duplicate.msg = f"{
|
371
|
+
duplicate.msg = f"{record.msg} :{intercepted.name}:"
|
358
372
|
interceptor.handle(duplicate)
|
359
373
|
|
360
374
|
return handle_p
|
logger_36/version.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: logger-36
|
3
|
-
Version: 2024.
|
3
|
+
Version: 2024.12
|
4
4
|
Summary: Simple logger with a catalog of handlers
|
5
5
|
Home-page: https://src.koda.cnrs.fr/eric.debreuve/logger-36/
|
6
6
|
Author: Eric Debreuve
|
@@ -60,7 +60,7 @@ Description-Content-Type: text/x-rst
|
|
60
60
|
.. _DOCUMENTATION_URL: https://src.koda.cnrs.fr/eric.debreuve/logger-36/-/wikis/home
|
61
61
|
|
62
62
|
.. |DEPENDENCIES_MANDATORY| replace:: None
|
63
|
-
.. |DEPENDENCIES_OPTIONAL| replace:: psutil, rich
|
63
|
+
.. |DEPENDENCIES_OPTIONAL| replace:: psutil, rich, tensorflow, tensorrt
|
64
64
|
|
65
65
|
|
66
66
|
|
@@ -1,26 +1,26 @@
|
|
1
1
|
logger_36/__init__.py,sha256=67ZAWtUx9Qy8Yn-tLQkOIEO6Z9U-8jhfm-tqNjjeFPU,1758
|
2
2
|
logger_36/instance.py,sha256=wAVty29f24SCs4FRL600QySlA_WeLUM78p4t_Ni-LzA,1618
|
3
3
|
logger_36/main.py,sha256=peXqcSDTrJhlKQkxSmum94BUJ8pIrtWTfvV9hUXp_pU,6558
|
4
|
-
logger_36/version.py,sha256=
|
5
|
-
logger_36/catalog/config/console_rich.py,sha256=
|
4
|
+
logger_36/version.py,sha256=VWuEdLsgvr2H_5EQUGJQ_Da2vgLayBLdFwB8hmM2hlU,1578
|
5
|
+
logger_36/catalog/config/console_rich.py,sha256=XKRKJx_5dxp4mgan1D-u_qrQos-pezRccqKsnmn-ook,2119
|
6
6
|
logger_36/catalog/handler/console.py,sha256=dm2-_1ZXUd6Gl1uyJaapPhUldzkEZ2fOlgeH8gxmpSs,3094
|
7
7
|
logger_36/catalog/handler/console_rich.py,sha256=TMP9fupSY8OdGb3jeMAeSLjOssJBgcdwkTDo4Enud5U,6513
|
8
8
|
logger_36/catalog/handler/file.py,sha256=tBShoy37F3riXDQc802feKzdpHQj5F3vqKaq211I1WI,3509
|
9
|
-
logger_36/catalog/handler/generic.py,sha256=
|
9
|
+
logger_36/catalog/handler/generic.py,sha256=peYlR-6N6uQDySIzJgl1KhBMSGG7bXGQOY2jnlyefxY,6324
|
10
10
|
logger_36/catalog/logging/chronos.py,sha256=zVe5ZwB63mqNqlIDm6ZBi4-U5n_n-21h8umhimRUcdU,1815
|
11
11
|
logger_36/catalog/logging/gpu.py,sha256=0XqVVK_TV1QPEwGXyK99jThHAjfsf-V__3m9Jh4gewk,2783
|
12
12
|
logger_36/catalog/logging/memory.py,sha256=-5SOXAV43RnXznBPbClVMpMqtMlVtBsI46w6ngz1oP4,4040
|
13
13
|
logger_36/catalog/logging/system.py,sha256=zomL8kRpmQuVP5KkcJkcUTnXK4ah3yn9PJb_cveNZDQ,2449
|
14
14
|
logger_36/config/issue.py,sha256=wAOChQMpGECw-4Jy0TWArOeQ1P134cGyKaVbc6NrwX8,1639
|
15
15
|
logger_36/config/memory.py,sha256=2OvnG7RMM1aZcUWBYGcNoBdLsQguo8cV862vCYSMbQs,1589
|
16
|
-
logger_36/config/message.py,sha256=
|
16
|
+
logger_36/config/message.py,sha256=fTZDkA6N9BBwfcTwRdEliAja0qPZwAdrxMORNFi1WLk,2021
|
17
17
|
logger_36/config/system.py,sha256=i39b-QNbg7i3BW_X-bHH9CqGO6mq1k9Ru5faYPi63SA,1849
|
18
18
|
logger_36/constant/error.py,sha256=mqlzrSdOJkuMxtRQnhNXosiGEYp8KInODBJIIdCNgbE,2197
|
19
19
|
logger_36/constant/generic.py,sha256=s0WHW-R_Eu2doDMoGERX3MtfCHmIW6uDjrDt_qP5MLA,1616
|
20
20
|
logger_36/constant/handler.py,sha256=Iw4Pnr5ZUMIeRSA0netupu4icDWoMYKLZRW7_JWbwiI,1683
|
21
21
|
logger_36/constant/issue.py,sha256=08BxREcVT0XnIFV3SrRQNd2uEOtnOP9VtscvRYXz1W4,1658
|
22
22
|
logger_36/constant/logger.py,sha256=-dE218OMVyIgHIIEiXgJ0a4p_76CJk6ULihU0MvJO1g,2152
|
23
|
-
logger_36/constant/memory.py,sha256
|
23
|
+
logger_36/constant/memory.py,sha256=gjQbcJt-bf6LluxPy40nY-UFJRQ7Z-zX1xi4BKTw9hI,1715
|
24
24
|
logger_36/constant/message.py,sha256=tklw8IIT8f29lmmkk-se3GM9SKzRvmdIEJTX9ZQu-dc,2086
|
25
25
|
logger_36/constant/record.py,sha256=oEwG4gjhN-Al_1cTjDLdvS_qYKUy4zkR5QUkYocT7eU,1683
|
26
26
|
logger_36/constant/system.py,sha256=dlEU4q-hSFAO6aAa6m_yCGfBwNH5AHTyVZbRFTZ0U0U,1802
|
@@ -31,10 +31,10 @@ logger_36/task/format/message.py,sha256=91CCgH7umLHUV_YRf4AyOsYZTgNVOvQSODqXO1wJ
|
|
31
31
|
logger_36/task/format/rule.py,sha256=cq4jl_ZCb8m7QoX8mWevXhy1hgwncLpc-9woKoT7m24,1970
|
32
32
|
logger_36/task/measure/chronos.py,sha256=7xZskYEXQCPDypmnlhn4KDCBB1v3eL1OE_sv-l3n8Do,2255
|
33
33
|
logger_36/task/measure/memory.py,sha256=aichGI-iCeE3Z4Y8AmWGdal2931IMdcdv4VgCeDLBoI,1876
|
34
|
-
logger_36/type/extension.py,sha256=
|
34
|
+
logger_36/type/extension.py,sha256=W4sS48WiUUQStWq7rt8gZxtilElpfNSVc6cG3j8kfDA,5992
|
35
35
|
logger_36/type/issue.py,sha256=OnkBKRTMsHvZ-2aLQWtBzGSWMTVs_4ermg71Ygcs0w8,2153
|
36
|
-
logger_36/type/logger.py,sha256=
|
37
|
-
logger_36-2024.
|
38
|
-
logger_36-2024.
|
39
|
-
logger_36-2024.
|
40
|
-
logger_36-2024.
|
36
|
+
logger_36/type/logger.py,sha256=f9xNOhIWNkyp_-30WxailksA1ERqFQpE4j0tomA0zqY,13197
|
37
|
+
logger_36-2024.12.dist-info/METADATA,sha256=_9EgXou4-f8fQ4tKhSwMjW5mgq9xCXWBcWEJEXs_vRQ,5592
|
38
|
+
logger_36-2024.12.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
39
|
+
logger_36-2024.12.dist-info/top_level.txt,sha256=sM95BTMWmslEEgR_1pzwZsOeSp8C_QBiu8ImbFr0XLc,10
|
40
|
+
logger_36-2024.12.dist-info/RECORD,,
|
File without changes
|
File without changes
|