logger-36 2025.5__py3-none-any.whl → 2025.7__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/api/logger.py +1 -1
- logger_36/api/storage.py +1 -1
- logger_36/catalog/config/console_rich.py +2 -2
- logger_36/catalog/config/optional.py +60 -0
- logger_36/catalog/handler/console.py +11 -9
- logger_36/catalog/handler/console_rich.py +16 -15
- logger_36/catalog/handler/file.py +10 -9
- logger_36/catalog/handler/generic.py +21 -16
- logger_36/catalog/logger/gpu.py +2 -2
- logger_36/constant/error.py +1 -1
- logger_36/constant/handler.py +2 -2
- logger_36/constant/logger.py +2 -9
- logger_36/{config/logger.py → constant/path.py} +15 -46
- logger_36/content.py +3 -3
- logger_36/exception.py +47 -12
- logger_36/gpu.py +1 -1
- logger_36/handler.py +15 -18
- logger_36/memory.py +9 -6
- logger_36/storage.py +1 -1
- logger_36/system.py +1 -1
- logger_36/task/format/rule.py +4 -2
- logger_36/task/measure/memory.py +2 -2
- logger_36/task/storage.py +7 -5
- logger_36/time.py +2 -2
- logger_36/type/handler.py +20 -4
- logger_36/type/logger.py +230 -123
- logger_36/version.py +1 -1
- {logger_36-2025.5.dist-info → logger_36-2025.7.dist-info}/METADATA +1 -1
- logger_36-2025.7.dist-info/RECORD +53 -0
- logger_36-2025.5.dist-info/RECORD +0 -52
- {logger_36-2025.5.dist-info → logger_36-2025.7.dist-info}/WHEEL +0 -0
- {logger_36-2025.5.dist-info → logger_36-2025.7.dist-info}/top_level.txt +0 -0
logger_36/handler.py
CHANGED
@@ -8,26 +8,23 @@ import logging as l
|
|
8
8
|
import sys as s
|
9
9
|
from pathlib import Path as path_t
|
10
10
|
|
11
|
+
from logger_36.catalog.config.optional import MISSING_RICH_MESSAGE, RICH_IS_AVAILABLE
|
11
12
|
from logger_36.catalog.handler.console import console_handler_t
|
12
13
|
from logger_36.catalog.handler.file import file_handler_t
|
13
|
-
from logger_36.catalog.handler.generic import
|
14
|
-
from logger_36.constant.error import MISSING_RICH_ERROR
|
14
|
+
from logger_36.catalog.handler.generic import LogAsIs_h, generic_handler_t
|
15
15
|
|
16
|
-
|
16
|
+
if RICH_IS_AVAILABLE:
|
17
17
|
from logger_36.catalog.handler.console_rich import console_rich_handler_t
|
18
|
-
|
19
|
-
_MISSING_RICH_ERROR = None
|
20
|
-
except ModuleNotFoundError:
|
18
|
+
else:
|
21
19
|
from logger_36.catalog.handler.console import (
|
22
20
|
console_handler_t as console_rich_handler_t,
|
23
21
|
)
|
24
|
-
|
25
|
-
_MISSING_RICH_ERROR = MISSING_RICH_ERROR
|
22
|
+
_MISSING_RICH_MESSAGE = MISSING_RICH_MESSAGE
|
26
23
|
|
27
24
|
|
28
25
|
def AddGenericHandler(
|
29
26
|
logger: l.Logger,
|
30
|
-
|
27
|
+
LogAsIs: LogAsIs_h,
|
31
28
|
/,
|
32
29
|
*,
|
33
30
|
name: str | None = None,
|
@@ -52,9 +49,9 @@ def AddGenericHandler(
|
|
52
49
|
alternating_lines=alternating_lines,
|
53
50
|
should_record=should_record,
|
54
51
|
rich_kwargs=kwargs,
|
55
|
-
|
52
|
+
LogAsIs=LogAsIs,
|
56
53
|
)
|
57
|
-
logger.AddHandler(handler, should_hold_messages)
|
54
|
+
logger.AddHandler(handler, should_hold_messages=should_hold_messages)
|
58
55
|
|
59
56
|
|
60
57
|
def AddConsoleHandler(
|
@@ -76,7 +73,7 @@ def AddConsoleHandler(
|
|
76
73
|
message_width=message_width,
|
77
74
|
formatter=formatter,
|
78
75
|
)
|
79
|
-
logger.AddHandler(handler, should_hold_messages)
|
76
|
+
logger.AddHandler(handler, should_hold_messages=should_hold_messages)
|
80
77
|
|
81
78
|
|
82
79
|
def AddRichConsoleHandler(
|
@@ -95,10 +92,10 @@ def AddRichConsoleHandler(
|
|
95
92
|
**kwargs,
|
96
93
|
) -> None:
|
97
94
|
""""""
|
98
|
-
global
|
99
|
-
if
|
100
|
-
print(
|
101
|
-
|
95
|
+
global _MISSING_RICH_MESSAGE
|
96
|
+
if _MISSING_RICH_MESSAGE is not None:
|
97
|
+
print(_MISSING_RICH_MESSAGE, file=s.stderr)
|
98
|
+
_MISSING_RICH_MESSAGE = None
|
102
99
|
|
103
100
|
if console_rich_handler_t is console_handler_t:
|
104
101
|
additional_s = {}
|
@@ -117,7 +114,7 @@ def AddRichConsoleHandler(
|
|
117
114
|
formatter=formatter,
|
118
115
|
**additional_s,
|
119
116
|
)
|
120
|
-
logger.AddHandler(handler, should_hold_messages)
|
117
|
+
logger.AddHandler(handler, should_hold_messages=should_hold_messages)
|
121
118
|
|
122
119
|
|
123
120
|
def AddFileHandler(
|
@@ -149,7 +146,7 @@ def AddFileHandler(
|
|
149
146
|
handler_args=args,
|
150
147
|
handler_kwargs=kwargs,
|
151
148
|
)
|
152
|
-
logger.AddHandler(handler, should_hold_messages)
|
149
|
+
logger.AddHandler(handler, should_hold_messages=should_hold_messages)
|
153
150
|
|
154
151
|
|
155
152
|
"""
|
logger_36/memory.py
CHANGED
@@ -4,14 +4,17 @@ Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
|
4
4
|
SEE COPYRIGHT NOTICE BELOW
|
5
5
|
"""
|
6
6
|
|
7
|
-
from logger_36.catalog.logger.memory import
|
8
|
-
|
9
|
-
|
7
|
+
from logger_36.catalog.logger.memory import ( # noqa
|
8
|
+
LogMaximumMemoryUsage,
|
9
|
+
LogMemoryUsages,
|
10
|
+
)
|
11
|
+
from logger_36.task.format.memory import FormattedUsage as FormattedMemoryUsage # noqa
|
12
|
+
from logger_36.task.format.memory import ( # noqa
|
10
13
|
FormattedUsageWithAutoUnit as FormattedMemoryUsageWithAutoUnit,
|
11
14
|
)
|
12
|
-
from logger_36.task.format.memory import UsageBar as MemoryUsageBar
|
13
|
-
from logger_36.task.measure.memory import CanCheckUsage as CanCheckMemoryUsage
|
14
|
-
from logger_36.task.measure.memory import CurrentUsage as CurrentMemoryUsage
|
15
|
+
from logger_36.task.format.memory import UsageBar as MemoryUsageBar # noqa
|
16
|
+
from logger_36.task.measure.memory import CanCheckUsage as CanCheckMemoryUsage # noqa
|
17
|
+
from logger_36.task.measure.memory import CurrentUsage as CurrentMemoryUsage # noqa
|
15
18
|
|
16
19
|
"""
|
17
20
|
COPYRIGHT NOTICE
|
logger_36/storage.py
CHANGED
logger_36/system.py
CHANGED
logger_36/task/format/rule.py
CHANGED
@@ -4,6 +4,8 @@ Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
|
4
4
|
SEE COPYRIGHT NOTICE BELOW
|
5
5
|
"""
|
6
6
|
|
7
|
+
from logger_36.catalog.config.optional import RICH_IS_AVAILABLE
|
8
|
+
|
7
9
|
|
8
10
|
def RuleAsText(text: str | None, /) -> str:
|
9
11
|
""""""
|
@@ -13,7 +15,7 @@ def RuleAsText(text: str | None, /) -> str:
|
|
13
15
|
return f"---- ---- ---- ---- {text} ---- ---- ---- ----"
|
14
16
|
|
15
17
|
|
16
|
-
|
18
|
+
if RICH_IS_AVAILABLE:
|
17
19
|
from rich.rule import Rule as rule_t # noqa
|
18
20
|
from rich.text import Text as text_t # noqa
|
19
21
|
|
@@ -24,7 +26,7 @@ try:
|
|
24
26
|
else:
|
25
27
|
return rule_t(title=text_t(text, style=f"bold {color}"), style=color)
|
26
28
|
|
27
|
-
|
29
|
+
else:
|
28
30
|
Rule = lambda _txt, _: RuleAsText(_txt)
|
29
31
|
|
30
32
|
"""
|
logger_36/task/measure/memory.py
CHANGED
logger_36/task/storage.py
CHANGED
@@ -6,17 +6,19 @@ SEE COPYRIGHT NOTICE BELOW
|
|
6
6
|
|
7
7
|
import dataclasses as d
|
8
8
|
import logging as l
|
9
|
-
import re as
|
9
|
+
import re as r
|
10
10
|
from html.parser import HTMLParser as html_parser_t
|
11
11
|
from io import IOBase as io_base_t
|
12
12
|
from pathlib import Path as path_t
|
13
13
|
|
14
|
-
|
14
|
+
from logger_36.catalog.config.optional import RICH_IS_AVAILABLE
|
15
|
+
from logger_36.instance.logger import L
|
16
|
+
|
17
|
+
if RICH_IS_AVAILABLE:
|
15
18
|
from rich.console import Console as console_t # noqa
|
16
|
-
|
19
|
+
else:
|
17
20
|
console_t = None
|
18
21
|
|
19
|
-
from logger_36.instance.logger import L
|
20
22
|
|
21
23
|
_BODY_END_PATTERN = r"</[bB][oO][dD][yY]>(.|\n)*$"
|
22
24
|
|
@@ -60,7 +62,7 @@ class html_reader_t(html_parser_t):
|
|
60
62
|
output[self.body_position_start[0] : (self.body_position_end[0] + 1)]
|
61
63
|
)
|
62
64
|
output = output[self.body_position_start[1] :]
|
63
|
-
output =
|
65
|
+
output = r.sub(_BODY_END_PATTERN, "", output, count=1)
|
64
66
|
|
65
67
|
return output.strip()
|
66
68
|
|
logger_36/time.py
CHANGED
@@ -4,8 +4,8 @@ Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
|
4
4
|
SEE COPYRIGHT NOTICE BELOW
|
5
5
|
"""
|
6
6
|
|
7
|
-
from logger_36.catalog.logger.chronos import LogElapsedTime
|
8
|
-
from logger_36.task.measure.chronos import ElapsedTime, TimeStamp
|
7
|
+
from logger_36.catalog.logger.chronos import LogElapsedTime # noqa
|
8
|
+
from logger_36.task.measure.chronos import ElapsedTime, TimeStamp # noqa
|
9
9
|
|
10
10
|
"""
|
11
11
|
COPYRIGHT NOTICE
|
logger_36/type/handler.py
CHANGED
@@ -16,12 +16,28 @@ from logger_36.config.message import (
|
|
16
16
|
WHERE_SEPARATOR,
|
17
17
|
)
|
18
18
|
from logger_36.constant.error import MEMORY_MEASURE_ERROR
|
19
|
-
from logger_36.constant.handler import
|
19
|
+
from logger_36.constant.handler import HANDLER_KINDS
|
20
20
|
from logger_36.constant.message import NEXT_LINE_PROLOGUE
|
21
21
|
from logger_36.task.format.message import MessageWithActualExpected
|
22
22
|
from logger_36.task.measure.chronos import TimeStamp
|
23
23
|
from logger_36.task.measure.memory import CanCheckUsage as CanCheckMemoryUsage
|
24
24
|
|
25
|
+
MessageFromRecordRaw_h = h.Callable[[l.LogRecord], str]
|
26
|
+
|
27
|
+
|
28
|
+
@h.runtime_checkable
|
29
|
+
class MessageFromRecordPreprocessed_p(h.Protocol):
|
30
|
+
def __call__(
|
31
|
+
self,
|
32
|
+
record: l.LogRecord,
|
33
|
+
/,
|
34
|
+
*,
|
35
|
+
PreProcessed: h.Callable[[str], str] | None = None,
|
36
|
+
) -> str: ...
|
37
|
+
|
38
|
+
|
39
|
+
MessageFromRecord_h = MessageFromRecordRaw_h | MessageFromRecordPreprocessed_p
|
40
|
+
|
25
41
|
_MEMORY_MEASURE_ERROR = MEMORY_MEASURE_ERROR
|
26
42
|
|
27
43
|
|
@@ -30,7 +46,7 @@ class handler_extension_t:
|
|
30
46
|
name: str | None = None
|
31
47
|
should_store_memory_usage: bool = False
|
32
48
|
message_width: int = -1
|
33
|
-
MessageFromRecord:
|
49
|
+
MessageFromRecord: MessageFromRecord_h = d.field(init=False)
|
34
50
|
|
35
51
|
handler: d.InitVar[l.Handler | None] = None
|
36
52
|
level: d.InitVar[int] = l.NOTSET
|
@@ -42,12 +58,12 @@ class handler_extension_t:
|
|
42
58
|
""""""
|
43
59
|
global _MEMORY_MEASURE_ERROR
|
44
60
|
|
45
|
-
if self.name in
|
61
|
+
if self.name in HANDLER_KINDS:
|
46
62
|
raise ValueError(
|
47
63
|
MessageWithActualExpected(
|
48
64
|
"Invalid handler name",
|
49
65
|
actual=self.name,
|
50
|
-
expected=f"a name not in {str(
|
66
|
+
expected=f"a name not in {str(HANDLER_KINDS)[1:-1]}",
|
51
67
|
)
|
52
68
|
)
|
53
69
|
|