logger-36 2025.12__py3-none-any.whl → 2025.14__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/handler/console.py +22 -49
- logger_36/catalog/handler/console_rich.py +73 -87
- logger_36/catalog/handler/file.py +24 -55
- logger_36/catalog/handler/generic.py +67 -68
- logger_36/catalog/logger/gpu.py +1 -1
- logger_36/catalog/logger/system.py +1 -1
- logger_36/config/message.py +1 -0
- logger_36/{api/handler.py → constant/html.py} +18 -6
- logger_36/extension/exception.py +4 -2
- logger_36/extension/line.py +83 -0
- logger_36/task/format/memory.py +1 -5
- logger_36/task/format/message.py +60 -1
- logger_36/task/format/rule.py +3 -2
- logger_36/task/inspection.py +1 -1
- logger_36/task/storage.py +29 -8
- logger_36/type/handler.py +101 -106
- logger_36/type/logger.py +92 -60
- logger_36/type/message.py +90 -0
- logger_36/version.py +1 -1
- {logger_36-2025.12.dist-info → logger_36-2025.14.dist-info}/METADATA +2 -2
- {logger_36-2025.12.dist-info → logger_36-2025.14.dist-info}/RECORD +23 -22
- {logger_36-2025.12.dist-info → logger_36-2025.14.dist-info}/WHEEL +1 -1
- logger_36/task/handling.py +0 -196
- {logger_36-2025.12.dist-info → logger_36-2025.14.dist-info}/top_level.txt +0 -0
@@ -4,73 +4,46 @@ Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
|
4
4
|
SEE COPYRIGHT NOTICE BELOW
|
5
5
|
"""
|
6
6
|
|
7
|
-
import dataclasses as d
|
8
7
|
import logging as l
|
9
8
|
import sys as s
|
10
9
|
import typing as h
|
11
10
|
|
12
|
-
from logger_36.constant.record import SHOW_W_RULE_ATTR
|
13
11
|
from logger_36.task.format.rule import RuleAsText
|
14
|
-
from logger_36.type.handler import
|
12
|
+
from logger_36.type.handler import handler_t as base_t
|
15
13
|
|
16
14
|
|
17
|
-
|
18
|
-
class console_handler_t(l.Handler):
|
19
|
-
"""
|
20
|
-
kind: See logger_36.constant.handler.handler_codes_h.
|
21
|
-
"""
|
22
|
-
|
15
|
+
class console_handler_t(base_t):
|
23
16
|
kind: h.ClassVar[str] = "c"
|
24
17
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
level: int,
|
38
|
-
should_store_memory_usage: bool,
|
39
|
-
message_width: int,
|
40
|
-
formatter: l.Formatter | None,
|
41
|
-
) -> None:
|
18
|
+
@classmethod
|
19
|
+
def New(
|
20
|
+
cls,
|
21
|
+
/,
|
22
|
+
*,
|
23
|
+
name: str | None = None,
|
24
|
+
should_store_memory_usage: bool = False,
|
25
|
+
message_width: int = -1,
|
26
|
+
level: int = l.NOTSET,
|
27
|
+
formatter: l.Formatter | None = None,
|
28
|
+
**_,
|
29
|
+
) -> h.Self:
|
42
30
|
""""""
|
43
|
-
|
44
|
-
|
45
|
-
self.extension = handler_extension_t(
|
46
|
-
name=name,
|
47
|
-
should_store_memory_usage=should_store_memory_usage,
|
48
|
-
handler=self,
|
49
|
-
level=level,
|
50
|
-
message_width=message_width,
|
51
|
-
formatter=formatter,
|
52
|
-
)
|
53
|
-
|
54
|
-
self.MessageFromRecord = self.extension.MessageFromRecord
|
31
|
+
return cls(name, should_store_memory_usage, message_width, level, formatter)
|
55
32
|
|
56
33
|
def emit(self, record: l.LogRecord, /) -> None:
|
57
34
|
""""""
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
s.__stdout__.write(message + "\n")
|
35
|
+
message = self.MessageFromRecord(
|
36
|
+
record, RuleAsText, line_width=self.message_width
|
37
|
+
)
|
38
|
+
s.__stdout__.write(message[0] + "\n")
|
63
39
|
|
64
40
|
def LogAsIs(self, message: str, /) -> None:
|
65
|
-
"""
|
66
|
-
See documentation of
|
67
|
-
logger_36.catalog.handler.generic.generic_handler_t.LogAsIs.
|
68
|
-
"""
|
41
|
+
""""""
|
69
42
|
s.__stdout__.write(message + "\n")
|
70
43
|
|
71
|
-
def DisplayRule(self, /, *, text: str | None = None, color: str = "
|
44
|
+
def DisplayRule(self, /, *, text: str | None = None, color: str = "black") -> None:
|
72
45
|
""""""
|
73
|
-
self.LogAsIs(RuleAsText(text))
|
46
|
+
self.LogAsIs(RuleAsText(text, None))
|
74
47
|
|
75
48
|
|
76
49
|
"""
|
@@ -4,10 +4,15 @@ Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
|
4
4
|
SEE COPYRIGHT NOTICE BELOW
|
5
5
|
"""
|
6
6
|
|
7
|
-
import dataclasses as d
|
8
7
|
import logging as l
|
9
8
|
import typing as h
|
10
9
|
|
10
|
+
from rich.console import Console as console_t # noqa
|
11
|
+
from rich.console import RenderableType as renderable_t # noqa
|
12
|
+
from rich.markup import escape as EscapedVersion # noqa
|
13
|
+
from rich.text import Text as text_t # noqa
|
14
|
+
from rich.traceback import install as InstallTracebackHandler # noqa
|
15
|
+
|
11
16
|
from logger_36.catalog.config.console_rich import (
|
12
17
|
ACTUAL_COLOR,
|
13
18
|
ALTERNATIVE_BACKGROUND_FOR_DARK,
|
@@ -20,14 +25,8 @@ from logger_36.catalog.config.console_rich import (
|
|
20
25
|
)
|
21
26
|
from logger_36.config.message import ACTUAL_PATTERNS, EXPECTED_PATTERNS, WHERE_SEPARATOR
|
22
27
|
from logger_36.constant.message import CONTEXT_LENGTH
|
23
|
-
from logger_36.constant.record import SHOW_W_RULE_ATTR
|
24
28
|
from logger_36.task.format.rule import Rule
|
25
|
-
from logger_36.type.handler import
|
26
|
-
from rich.console import Console as console_t # noqa
|
27
|
-
from rich.console import RenderableType as renderable_t # noqa
|
28
|
-
from rich.markup import escape as EscapedVersion # noqa
|
29
|
-
from rich.text import Text as text_t # noqa
|
30
|
-
from rich.traceback import install as InstallTracebackHandler # noqa
|
29
|
+
from logger_36.type.handler import handler_t as base_t
|
31
30
|
|
32
31
|
_COMMON_TRACEBACK_ARGUMENTS = ("theme", "width")
|
33
32
|
_EXCLUSIVE_TRACEBACK_ARGUMENTS = (
|
@@ -37,17 +36,14 @@ _EXCLUSIVE_TRACEBACK_ARGUMENTS = (
|
|
37
36
|
"locals_hide_sunder",
|
38
37
|
"locals_max_length",
|
39
38
|
"locals_max_string",
|
40
|
-
"
|
39
|
+
"max_framesshow_locals",
|
41
40
|
"suppress",
|
42
41
|
"word_wrap",
|
43
42
|
)
|
44
43
|
|
45
44
|
|
46
|
-
|
47
|
-
class console_rich_handler_t(l.Handler):
|
45
|
+
class console_rich_handler_t(base_t):
|
48
46
|
"""
|
49
|
-
kind: See logger_36.constant.handler.handler_codes_h.
|
50
|
-
|
51
47
|
alternating_logs:
|
52
48
|
- 0: disabled
|
53
49
|
- 1: enabled for dark background
|
@@ -56,105 +52,95 @@ class console_rich_handler_t(l.Handler):
|
|
56
52
|
|
57
53
|
kind: h.ClassVar[str] = "c"
|
58
54
|
|
59
|
-
|
60
|
-
|
61
|
-
name: d.InitVar[str | None] = None
|
62
|
-
level: d.InitVar[int] = l.NOTSET
|
63
|
-
should_store_memory_usage: d.InitVar[bool] = False
|
64
|
-
message_width: d.InitVar[int] = -1
|
65
|
-
formatter: d.InitVar[l.Formatter | None] = None
|
66
|
-
#
|
67
|
-
should_install_traceback: d.InitVar[bool] = False
|
68
|
-
should_record: d.InitVar[bool] = False
|
69
|
-
rich_kwargs: d.InitVar[dict[str, h.Any] | None] = None
|
70
|
-
|
71
|
-
extension: handler_extension_t = d.field(init=False)
|
72
|
-
console: console_t = d.field(init=False)
|
73
|
-
MessageFromRecord: MessageFromRecordPreprocessed_p = d.field(init=False)
|
74
|
-
log_parity: bool = d.field(init=False, default=False)
|
75
|
-
|
76
|
-
@property
|
77
|
-
def past_logs_as_HTML(self) -> str | None:
|
78
|
-
""""""
|
79
|
-
console = self.console
|
80
|
-
if console.record:
|
81
|
-
return console.export_html()
|
82
|
-
|
83
|
-
return None
|
84
|
-
|
85
|
-
def __post_init__(
|
55
|
+
def __init__(
|
86
56
|
self,
|
87
57
|
name: str | None,
|
88
|
-
level: int,
|
89
58
|
should_store_memory_usage: bool,
|
90
59
|
message_width: int,
|
60
|
+
level: int,
|
91
61
|
formatter: l.Formatter | None,
|
92
|
-
|
93
|
-
should_record: bool,
|
94
|
-
rich_kwargs: dict[str, h.Any] | None,
|
62
|
+
kwargs,
|
95
63
|
) -> None:
|
96
64
|
""""""
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
65
|
+
alternating_logs = kwargs.pop("alternating_logs", 0)
|
66
|
+
should_install_traceback = kwargs.pop("should_install_traceback", False)
|
67
|
+
|
68
|
+
assert alternating_logs in (0, 1, 2)
|
69
|
+
|
70
|
+
base_t.__init__(
|
71
|
+
self,
|
72
|
+
name,
|
73
|
+
should_store_memory_usage,
|
74
|
+
message_width,
|
75
|
+
level,
|
76
|
+
formatter,
|
77
|
+
kwargs,
|
106
78
|
)
|
107
79
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
80
|
+
self.console = None # console_t | None.
|
81
|
+
self.alternating_logs = alternating_logs
|
82
|
+
self._log_parity = False
|
83
|
+
|
84
|
+
self.__post_init_local__(should_install_traceback, **kwargs)
|
85
|
+
|
86
|
+
def __post_init_local__(self, should_install_traceback: bool, **kwargs) -> None:
|
87
|
+
""""""
|
88
|
+
traceback_kwargs = {}
|
113
89
|
if should_install_traceback:
|
114
|
-
for key in
|
90
|
+
for key in kwargs:
|
115
91
|
if key in _COMMON_TRACEBACK_ARGUMENTS:
|
116
|
-
|
92
|
+
traceback_kwargs[key] = kwargs[key]
|
117
93
|
elif key in _EXCLUSIVE_TRACEBACK_ARGUMENTS:
|
118
|
-
|
119
|
-
del rich_console_kwargs[key]
|
120
|
-
|
121
|
-
self.console = console_t(
|
122
|
-
highlight=False,
|
123
|
-
force_terminal=True,
|
124
|
-
record=should_record,
|
125
|
-
**rich_console_kwargs,
|
126
|
-
)
|
127
|
-
if should_install_traceback:
|
128
|
-
rich_traceback_kwargs["console"] = self.console
|
129
|
-
InstallTracebackHandler(**rich_traceback_kwargs)
|
94
|
+
traceback_kwargs[key] = kwargs.pop(key)
|
130
95
|
|
131
|
-
self.
|
132
|
-
|
96
|
+
self.console = console_t(highlight=False, force_terminal=True, **kwargs)
|
97
|
+
|
98
|
+
if should_install_traceback:
|
99
|
+
traceback_kwargs["console"] = self.console
|
100
|
+
InstallTracebackHandler(**traceback_kwargs)
|
101
|
+
|
102
|
+
@classmethod
|
103
|
+
def New(
|
104
|
+
cls,
|
105
|
+
/,
|
106
|
+
*,
|
107
|
+
name: str | None = None,
|
108
|
+
should_store_memory_usage: bool = False,
|
109
|
+
message_width: int = -1,
|
110
|
+
level: int = l.NOTSET,
|
111
|
+
formatter: l.Formatter | None = None,
|
112
|
+
**kwargs,
|
113
|
+
) -> h.Self:
|
114
|
+
""""""
|
115
|
+
return cls(
|
116
|
+
name, should_store_memory_usage, message_width, level, formatter, kwargs
|
117
|
+
)
|
133
118
|
|
134
119
|
def emit(self, record: l.LogRecord, /) -> None:
|
135
120
|
""""""
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
121
|
+
message, is_not_a_rule = self.MessageFromRecord(
|
122
|
+
record,
|
123
|
+
Rule,
|
124
|
+
line_width=self.message_width,
|
125
|
+
color=DATE_TIME_COLOR,
|
126
|
+
PreProcessed=EscapedVersion,
|
127
|
+
)
|
128
|
+
if is_not_a_rule:
|
129
|
+
message = HighlightedVersion(
|
141
130
|
self.console,
|
142
131
|
message,
|
143
132
|
record.levelno,
|
144
133
|
self.alternating_logs,
|
145
|
-
self.
|
134
|
+
self._log_parity,
|
146
135
|
)
|
147
|
-
self.console.print(
|
148
|
-
self.
|
136
|
+
self.console.print(message, crop=False, overflow="ignore")
|
137
|
+
self._log_parity = not self._log_parity
|
149
138
|
|
150
139
|
def LogAsIs(self, message: str | renderable_t, /) -> None:
|
151
|
-
"""
|
152
|
-
See documentation of
|
153
|
-
logger_36.catalog.handler.generic.generic_handler_t.LogAsIs.
|
154
|
-
"""
|
140
|
+
""""""
|
155
141
|
self.console.print(message, crop=False, overflow="ignore")
|
156
142
|
|
157
|
-
def DisplayRule(self, /, *, text: str | None = None, color: str = "
|
143
|
+
def DisplayRule(self, /, *, text: str | None = None, color: str = "black") -> None:
|
158
144
|
""""""
|
159
145
|
self.LogAsIs(Rule(text, color))
|
160
146
|
|
@@ -4,82 +4,51 @@ Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
|
4
4
|
SEE COPYRIGHT NOTICE BELOW
|
5
5
|
"""
|
6
6
|
|
7
|
-
import dataclasses as d
|
8
7
|
import logging as l
|
9
8
|
import typing as h
|
10
9
|
from pathlib import Path as path_t
|
11
10
|
|
12
|
-
from logger_36.constant.record import SHOW_W_RULE_ATTR
|
13
11
|
from logger_36.task.format.rule import RuleAsText
|
14
|
-
from logger_36.type.handler import
|
12
|
+
from logger_36.type.handler import file_handler_t as base_t
|
15
13
|
|
16
14
|
|
17
|
-
|
18
|
-
class file_handler_t(l.FileHandler):
|
19
|
-
"""
|
20
|
-
kind: See logger_36.constant.handler.handler_codes_h.
|
21
|
-
"""
|
22
|
-
|
15
|
+
class file_handler_t(base_t):
|
23
16
|
kind: h.ClassVar[str] = "f"
|
24
17
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
def __post_init__(
|
39
|
-
self,
|
40
|
-
name: str | None,
|
41
|
-
level: int,
|
42
|
-
should_store_memory_usage: bool,
|
43
|
-
message_width: int,
|
44
|
-
formatter: l.Formatter | None,
|
45
|
-
path: path_t | None,
|
46
|
-
handler_args: tuple[h.Any, ...] | None,
|
47
|
-
handler_kwargs: dict[str, h.Any] | None,
|
48
|
-
) -> None:
|
18
|
+
@classmethod
|
19
|
+
def New(
|
20
|
+
cls,
|
21
|
+
/,
|
22
|
+
*,
|
23
|
+
name: str | None = None,
|
24
|
+
should_store_memory_usage: bool = False,
|
25
|
+
message_width: int = -1,
|
26
|
+
level: int = l.NOTSET,
|
27
|
+
formatter: l.Formatter | None = None,
|
28
|
+
path: str | path_t | None = None,
|
29
|
+
**_,
|
30
|
+
) -> h.Self:
|
49
31
|
""""""
|
50
|
-
|
51
|
-
|
52
|
-
self.extension = handler_extension_t(
|
53
|
-
name=name,
|
54
|
-
should_store_memory_usage=should_store_memory_usage,
|
55
|
-
handler=self,
|
56
|
-
level=level,
|
57
|
-
message_width=message_width,
|
58
|
-
formatter=formatter,
|
32
|
+
return cls(
|
33
|
+
name, should_store_memory_usage, message_width, level, formatter, path
|
59
34
|
)
|
60
35
|
|
61
|
-
self.MessageFromRecord = self.extension.MessageFromRecord
|
62
|
-
|
63
36
|
def emit(self, record: l.LogRecord, /) -> None:
|
64
37
|
""""""
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
self.stream.write(message + "\n")
|
38
|
+
message = self.MessageFromRecord(
|
39
|
+
record, RuleAsText, line_width=self.message_width
|
40
|
+
)
|
41
|
+
self.stream.write(message[0] + "\n")
|
70
42
|
self.stream.flush()
|
71
43
|
|
72
44
|
def LogAsIs(self, message: str, /) -> None:
|
73
|
-
"""
|
74
|
-
See documentation of
|
75
|
-
logger_36.catalog.handler.generic.generic_handler_t.LogAsIs.
|
76
|
-
"""
|
45
|
+
""""""
|
77
46
|
self.stream.write(message + "\n")
|
78
47
|
self.stream.flush()
|
79
48
|
|
80
|
-
def DisplayRule(self, /, *, text: str | None = None, color: str = "
|
49
|
+
def DisplayRule(self, /, *, text: str | None = None, color: str = "black") -> None:
|
81
50
|
""""""
|
82
|
-
self.LogAsIs(RuleAsText(text))
|
51
|
+
self.LogAsIs(RuleAsText(text, None))
|
83
52
|
|
84
53
|
|
85
54
|
"""
|
@@ -4,27 +4,26 @@ Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
|
4
4
|
SEE COPYRIGHT NOTICE BELOW
|
5
5
|
"""
|
6
6
|
|
7
|
-
import dataclasses as d
|
8
7
|
import logging as l
|
9
8
|
import typing as h
|
10
9
|
|
11
10
|
from logger_36.catalog.config.optional import RICH_IS_AVAILABLE
|
12
11
|
|
13
12
|
if RICH_IS_AVAILABLE:
|
14
|
-
from logger_36.catalog.config.console_rich import DATE_TIME_COLOR
|
15
|
-
from logger_36.catalog.handler.console_rich import HighlightedVersion
|
16
13
|
from rich.console import Console as console_t # noqa
|
17
14
|
from rich.console import ConsoleOptions as console_options_t # noqa
|
18
15
|
from rich.markup import escape as EscapedForRich # noqa
|
19
16
|
from rich.terminal_theme import DEFAULT_TERMINAL_THEME # noqa
|
17
|
+
|
18
|
+
from logger_36.catalog.config.console_rich import DATE_TIME_COLOR
|
19
|
+
from logger_36.catalog.handler.console_rich import HighlightedVersion
|
20
20
|
else:
|
21
21
|
DATE_TIME_COLOR = HighlightedVersion = console_t = console_options_t = (
|
22
22
|
EscapedForRich
|
23
23
|
) = DEFAULT_TERMINAL_THEME = None
|
24
24
|
|
25
|
-
from logger_36.
|
26
|
-
from logger_36.
|
27
|
-
from logger_36.type.handler import MessageFromRecord_h, handler_extension_t
|
25
|
+
from logger_36.task.format.rule import Rule, RuleAsText, rule_t
|
26
|
+
from logger_36.type.handler import handler_t as base_t
|
28
27
|
|
29
28
|
LogAsIs_h = h.Callable[[str | h.Any], None]
|
30
29
|
|
@@ -34,11 +33,8 @@ class DisplayRule_p(h.Protocol):
|
|
34
33
|
def __call__(self, /, *, text: str | None = None, color: str = "white") -> None: ...
|
35
34
|
|
36
35
|
|
37
|
-
|
38
|
-
class generic_handler_t(l.Handler):
|
36
|
+
class generic_handler_t(base_t):
|
39
37
|
"""
|
40
|
-
kind: See logger_36.constant.handler.handler_codes_h.
|
41
|
-
|
42
38
|
alternating_logs:
|
43
39
|
- 0: disabled
|
44
40
|
- 1: enabled for dark background
|
@@ -57,59 +53,45 @@ class generic_handler_t(l.Handler):
|
|
57
53
|
|
58
54
|
kind: h.ClassVar[str] = "g"
|
59
55
|
|
60
|
-
|
61
|
-
# "None -> h.Any" (twice below) since None | None is invalid.
|
62
|
-
console: console_t | h.Any = None
|
63
|
-
console_options: console_options_t | h.Any = None
|
64
|
-
alternating_logs: int = 0
|
65
|
-
|
66
|
-
DisplayRule: DisplayRule_p = d.field(init=False)
|
67
|
-
extension: handler_extension_t = d.field(init=False)
|
68
|
-
MessageFromRecord: MessageFromRecord_h = d.field(init=False)
|
69
|
-
log_parity: bool = d.field(init=False, default=False)
|
70
|
-
|
71
|
-
name: d.InitVar[str | None] = None
|
72
|
-
level: d.InitVar[int] = l.NOTSET
|
73
|
-
should_store_memory_usage: d.InitVar[bool] = False
|
74
|
-
message_width: d.InitVar[int] = -1
|
75
|
-
formatter: d.InitVar[l.Formatter | None] = None
|
76
|
-
#
|
77
|
-
supports_html: d.InitVar[bool] = False
|
78
|
-
should_record: d.InitVar[bool] = False
|
79
|
-
rich_kwargs: d.InitVar[dict[str, h.Any] | None] = None
|
80
|
-
|
81
|
-
def __post_init__(
|
56
|
+
def __init__(
|
82
57
|
self,
|
83
58
|
name: str | None,
|
84
|
-
level: int,
|
85
59
|
should_store_memory_usage: bool,
|
86
60
|
message_width: int,
|
61
|
+
level: int,
|
87
62
|
formatter: l.Formatter | None,
|
88
|
-
|
89
|
-
should_record: bool,
|
90
|
-
rich_kwargs: dict[str, h.Any] | None,
|
63
|
+
kwargs,
|
91
64
|
) -> None:
|
92
65
|
""""""
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
66
|
+
alternating_logs = kwargs.pop("alternating_logs", 0)
|
67
|
+
LogAsIs = kwargs.pop("LogAsIs", lambda _, indented=False: print(_))
|
68
|
+
supports_html = kwargs.pop("supports_html", False)
|
69
|
+
|
70
|
+
assert alternating_logs in (0, 1, 2)
|
71
|
+
|
72
|
+
base_t.__init__(
|
73
|
+
self,
|
74
|
+
name,
|
75
|
+
should_store_memory_usage,
|
76
|
+
message_width,
|
77
|
+
level,
|
78
|
+
formatter,
|
79
|
+
kwargs,
|
102
80
|
)
|
103
81
|
|
82
|
+
self.LogAsIs = LogAsIs
|
83
|
+
self.DisplayRule = None # DisplayRule_p | None.
|
84
|
+
self.console = None # console_t | None.
|
85
|
+
self.console_options = None # console_options_t | None.
|
86
|
+
self.alternating_logs = alternating_logs
|
87
|
+
self._log_parity = False
|
88
|
+
|
89
|
+
self.__post_init_local__(supports_html)
|
90
|
+
|
91
|
+
def __post_init_local__(self, supports_html: bool) -> None:
|
92
|
+
""""""
|
104
93
|
if supports_html and (console_t is not None):
|
105
|
-
|
106
|
-
rich_kwargs = {}
|
107
|
-
self.console = console_t(
|
108
|
-
highlight=False,
|
109
|
-
force_terminal=True,
|
110
|
-
record=should_record,
|
111
|
-
**rich_kwargs,
|
112
|
-
)
|
94
|
+
self.console = console_t(highlight=False, force_terminal=True)
|
113
95
|
self.console_options = self.console.options.update(
|
114
96
|
overflow="ignore", no_wrap=True
|
115
97
|
)
|
@@ -117,29 +99,46 @@ class generic_handler_t(l.Handler):
|
|
117
99
|
else:
|
118
100
|
self.DisplayRule = self._DisplayRuleAsText
|
119
101
|
|
120
|
-
|
121
|
-
|
102
|
+
@classmethod
|
103
|
+
def New(
|
104
|
+
cls,
|
105
|
+
/,
|
106
|
+
*,
|
107
|
+
name: str | None = None,
|
108
|
+
should_store_memory_usage: bool = False,
|
109
|
+
message_width: int = -1,
|
110
|
+
level: int = l.NOTSET,
|
111
|
+
formatter: l.Formatter | None = None,
|
112
|
+
**kwargs,
|
113
|
+
) -> h.Self:
|
114
|
+
""""""
|
115
|
+
return cls(
|
116
|
+
name, should_store_memory_usage, message_width, level, formatter, kwargs
|
117
|
+
)
|
122
118
|
|
123
119
|
def emit(self, record: l.LogRecord, /) -> None:
|
124
120
|
""""""
|
125
121
|
if self.console is None:
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
message = self.MessageFromRecord(record)
|
122
|
+
message = self.MessageFromRecord(
|
123
|
+
record, RuleAsText, line_width=self.message_width
|
124
|
+
)[0]
|
130
125
|
else:
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
126
|
+
message, is_not_a_rule = self.MessageFromRecord(
|
127
|
+
record,
|
128
|
+
Rule,
|
129
|
+
line_width=self.message_width,
|
130
|
+
color=DATE_TIME_COLOR,
|
131
|
+
PreProcessed=EscapedForRich,
|
132
|
+
)
|
133
|
+
if is_not_a_rule:
|
134
|
+
message = HighlightedVersion(
|
136
135
|
self.console,
|
137
136
|
message,
|
138
137
|
record.levelno,
|
139
138
|
self.alternating_logs,
|
140
|
-
self.
|
139
|
+
self._log_parity,
|
141
140
|
)
|
142
|
-
segments = self.console.render(
|
141
|
+
segments = self.console.render(message, options=self.console_options)
|
143
142
|
|
144
143
|
# Inspired from the code of: rich.console.export_html.
|
145
144
|
html_segments = []
|
@@ -164,13 +163,13 @@ class generic_handler_t(l.Handler):
|
|
164
163
|
)
|
165
164
|
|
166
165
|
self.LogAsIs(message)
|
167
|
-
self.
|
166
|
+
self._log_parity = not self._log_parity
|
168
167
|
|
169
168
|
def _DisplayRuleAsText(
|
170
169
|
self, /, *, text: str | None = None, color: str = "white"
|
171
170
|
) -> None:
|
172
171
|
""""""
|
173
|
-
self.LogAsIs(RuleAsText(text))
|
172
|
+
self.LogAsIs(RuleAsText(text, None))
|
174
173
|
|
175
174
|
def _DisplayRule(self, /, *, text: str | None = None, color: str = "white") -> None:
|
176
175
|
""""""
|
logger_36/catalog/logger/gpu.py
CHANGED
@@ -39,7 +39,7 @@ def LogGPURelatedDetails(*, logger: logger_t = L) -> None:
|
|
39
39
|
f" CuDNN: {system_details['cudnn_version']}\n"
|
40
40
|
f" Tensorflow: {tsfl.version.VERSION}\n"
|
41
41
|
f" Tensorflow Build: {tsfl.sysconfig.get_build_info()}\n"
|
42
|
-
f" TensorRT: {tsrt.__version__}"
|
42
|
+
f" TensorRT: {tsrt.__version__}"
|
43
43
|
)
|
44
44
|
|
45
45
|
|