logger-36 2025.4__py3-none-any.whl → 2025.6__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/__init__.py +2 -1
- logger_36/api/logger.py +1 -1
- logger_36/api/storage.py +1 -1
- logger_36/catalog/config/console_rich.py +9 -9
- logger_36/{config/logger.py → catalog/config/optional.py} +8 -51
- logger_36/catalog/handler/console.py +15 -8
- logger_36/catalog/handler/console_rich.py +20 -13
- logger_36/catalog/handler/file.py +14 -8
- logger_36/catalog/handler/generic.py +20 -12
- logger_36/catalog/logger/chronos.py +2 -2
- logger_36/catalog/logger/gpu.py +6 -6
- logger_36/catalog/logger/memory.py +3 -3
- logger_36/catalog/logger/system.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/content.py +3 -3
- logger_36/exception.py +51 -17
- logger_36/gpu.py +1 -1
- logger_36/handler.py +28 -41
- logger_36/instance/logger.py +1 -1
- 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/inspection.py +3 -3
- logger_36/task/measure/chronos.py +1 -3
- logger_36/task/measure/memory.py +2 -2
- logger_36/task/storage.py +16 -16
- logger_36/time.py +2 -2
- logger_36/type/handler.py +31 -12
- logger_36/type/issue.py +2 -2
- logger_36/type/logger.py +90 -44
- logger_36/version.py +1 -1
- {logger_36-2025.4.dist-info → logger_36-2025.6.dist-info}/METADATA +1 -1
- logger_36-2025.6.dist-info/RECORD +52 -0
- logger_36-2025.4.dist-info/RECORD +0 -52
- {logger_36-2025.4.dist-info → logger_36-2025.6.dist-info}/WHEEL +0 -0
- {logger_36-2025.4.dist-info → logger_36-2025.6.dist-info}/top_level.txt +0 -0
logger_36/__init__.py
CHANGED
@@ -11,12 +11,13 @@ except ModuleNotFoundError:
|
|
11
11
|
else:
|
12
12
|
import site
|
13
13
|
from pathlib import Path as path_t
|
14
|
+
|
14
15
|
paths = site.getsitepackages() + [site.getusersitepackages()]
|
15
16
|
folder = path_t(__file__).parent
|
16
17
|
if folder not in paths:
|
17
18
|
beartype_this_package()
|
18
19
|
|
19
|
-
from logger_36.instance.logger import
|
20
|
+
from logger_36.instance.logger import L
|
20
21
|
from logger_36.version import __version__
|
21
22
|
|
22
23
|
"""
|
logger_36/api/logger.py
CHANGED
logger_36/api/storage.py
CHANGED
@@ -4,10 +4,10 @@ Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
|
4
4
|
SEE COPYRIGHT NOTICE BELOW
|
5
5
|
"""
|
6
6
|
|
7
|
-
import logging as
|
7
|
+
import logging as l
|
8
8
|
|
9
|
-
from rich.color import Color as color_t
|
10
|
-
from rich.style import Style as style_t
|
9
|
+
from rich.color import Color as color_t # noqa
|
10
|
+
from rich.style import Style as style_t # noqa
|
11
11
|
|
12
12
|
"""
|
13
13
|
Colors: See https://rich.readthedocs.io/en/stable/appendix/colors.html.
|
@@ -16,13 +16,13 @@ WHITE_COLOR = "grey85"
|
|
16
16
|
GRAY_COLOR = "grey58"
|
17
17
|
|
18
18
|
LEVEL_COLOR: dict[int, str | style_t] = {
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
l.DEBUG: "orchid",
|
20
|
+
l.INFO: GRAY_COLOR,
|
21
|
+
l.WARNING: "yellow1",
|
22
|
+
l.ERROR: "dark_orange",
|
23
|
+
l.CRITICAL: "bright_red",
|
24
24
|
}
|
25
|
-
ACTUAL_COLOR = LEVEL_COLOR[
|
25
|
+
ACTUAL_COLOR = LEVEL_COLOR[l.CRITICAL]
|
26
26
|
EXPECTED_COLOR = "green3"
|
27
27
|
DATE_TIME_COLOR = "sky_blue3"
|
28
28
|
|
@@ -4,57 +4,14 @@ Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
|
4
4
|
SEE COPYRIGHT NOTICE BELOW
|
5
5
|
"""
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
from logger_36.
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
from logger_36.task.format.message import MessageWithActualExpected
|
16
|
-
|
17
|
-
|
18
|
-
def SetLOGLevel(
|
19
|
-
level: int,
|
20
|
-
/,
|
21
|
-
*,
|
22
|
-
logger: lggg.Logger | None = None,
|
23
|
-
which: handler_codes_h | str = "a",
|
24
|
-
) -> None:
|
25
|
-
"""
|
26
|
-
which: g=generic, c=console, f=file, a=all, str=name.
|
27
|
-
"""
|
28
|
-
if logger is None:
|
29
|
-
logger = LOGGER
|
30
|
-
|
31
|
-
which_is_name = which not in HANDLER_CODES
|
32
|
-
found = False
|
33
|
-
for handler in logger.handlers:
|
34
|
-
if (
|
35
|
-
(which == "a")
|
36
|
-
or ((which == "g") and isinstance(handler, generic_handler_t))
|
37
|
-
or (
|
38
|
-
(which == "c")
|
39
|
-
and isinstance(handler, (console_handler_t, console_rich_handler_t))
|
40
|
-
)
|
41
|
-
or ((which == "f") and isinstance(handler, file_handler_t))
|
42
|
-
or (which == handler.name)
|
43
|
-
):
|
44
|
-
handler.setLevel(level)
|
45
|
-
if which_is_name:
|
46
|
-
return
|
47
|
-
found = True
|
48
|
-
|
49
|
-
if not found:
|
50
|
-
raise ValueError(
|
51
|
-
MessageWithActualExpected(
|
52
|
-
"Handler not found",
|
53
|
-
actual=which,
|
54
|
-
expected=f"{str(HANDLER_CODES)[1:-1]}, or a handler name",
|
55
|
-
)
|
56
|
-
)
|
57
|
-
|
7
|
+
try:
|
8
|
+
import rich # noqa
|
9
|
+
except ModuleNotFoundError:
|
10
|
+
RICH_IS_AVAILABLE = False
|
11
|
+
from logger_36.constant.error import MISSING_RICH_MESSAGE
|
12
|
+
else:
|
13
|
+
RICH_IS_AVAILABLE = True
|
14
|
+
MISSING_RICH_MESSAGE = None
|
58
15
|
|
59
16
|
"""
|
60
17
|
COPYRIGHT NOTICE
|
@@ -5,7 +5,7 @@ SEE COPYRIGHT NOTICE BELOW
|
|
5
5
|
"""
|
6
6
|
|
7
7
|
import dataclasses as d
|
8
|
-
import logging as
|
8
|
+
import logging as l
|
9
9
|
import textwrap as txt_
|
10
10
|
import typing as h
|
11
11
|
|
@@ -13,18 +13,25 @@ from logger_36.constant.message import LINE_INDENT
|
|
13
13
|
from logger_36.constant.record import SHOW_W_RULE_ATTR
|
14
14
|
from logger_36.task.format.rule import RuleAsText
|
15
15
|
from logger_36.type.handler import handler_extension_t
|
16
|
+
from logger_36.type.handler import message_from_record_raw_p as message_from_record_p
|
16
17
|
|
17
18
|
|
18
19
|
@d.dataclass(slots=True, repr=False, eq=False)
|
19
|
-
class console_handler_t(
|
20
|
+
class console_handler_t(l.Handler):
|
21
|
+
"""
|
22
|
+
kind: See logger_36.constant.handler.handler_codes_h.
|
23
|
+
"""
|
24
|
+
|
25
|
+
kind: h.ClassVar[str] = "c"
|
26
|
+
|
20
27
|
extension: handler_extension_t = d.field(init=False)
|
21
|
-
MessageFromRecord:
|
28
|
+
MessageFromRecord: message_from_record_p = d.field(init=False)
|
22
29
|
|
23
30
|
name: d.InitVar[str | None] = None
|
24
|
-
level: d.InitVar[int] =
|
31
|
+
level: d.InitVar[int] = l.NOTSET
|
25
32
|
should_store_memory_usage: d.InitVar[bool] = False
|
26
33
|
message_width: d.InitVar[int] = -1
|
27
|
-
formatter: d.InitVar[
|
34
|
+
formatter: d.InitVar[l.Formatter | None] = None
|
28
35
|
|
29
36
|
def __post_init__(
|
30
37
|
self,
|
@@ -32,10 +39,10 @@ class console_handler_t(lggg.Handler):
|
|
32
39
|
level: int,
|
33
40
|
should_store_memory_usage: bool,
|
34
41
|
message_width: int,
|
35
|
-
formatter:
|
42
|
+
formatter: l.Formatter | None,
|
36
43
|
) -> None:
|
37
44
|
""""""
|
38
|
-
|
45
|
+
l.Handler.__init__(self)
|
39
46
|
|
40
47
|
self.extension = handler_extension_t(
|
41
48
|
name=name,
|
@@ -48,7 +55,7 @@ class console_handler_t(lggg.Handler):
|
|
48
55
|
|
49
56
|
self.MessageFromRecord = self.extension.MessageFromRecord
|
50
57
|
|
51
|
-
def emit(self, record:
|
58
|
+
def emit(self, record: l.LogRecord, /) -> None:
|
52
59
|
""""""
|
53
60
|
if hasattr(record, SHOW_W_RULE_ATTR):
|
54
61
|
message = RuleAsText(record.msg)
|
@@ -5,7 +5,7 @@ SEE COPYRIGHT NOTICE BELOW
|
|
5
5
|
"""
|
6
6
|
|
7
7
|
import dataclasses as d
|
8
|
-
import logging as
|
8
|
+
import logging as l
|
9
9
|
import textwrap as txt_
|
10
10
|
import typing as h
|
11
11
|
|
@@ -24,11 +24,14 @@ from logger_36.constant.message import CONTEXT_LENGTH, LINE_INDENT
|
|
24
24
|
from logger_36.constant.record import SHOW_W_RULE_ATTR
|
25
25
|
from logger_36.task.format.rule import Rule, rule_t
|
26
26
|
from logger_36.type.handler import handler_extension_t
|
27
|
-
from
|
28
|
-
|
29
|
-
|
30
|
-
from rich.
|
31
|
-
from rich.
|
27
|
+
from logger_36.type.handler import (
|
28
|
+
message_from_record_preprocessed_p as message_from_record_p,
|
29
|
+
)
|
30
|
+
from rich.console import Console as console_t # noqa
|
31
|
+
from rich.console import RenderableType as renderable_t # noqa
|
32
|
+
from rich.markup import escape as EscapedVersion # noqa
|
33
|
+
from rich.text import Text as text_t # noqa
|
34
|
+
from rich.traceback import install as InstallTracebackHandler # noqa
|
32
35
|
|
33
36
|
_COMMON_TRACEBACK_ARGUMENTS = ("theme", "width")
|
34
37
|
_EXCLUSIVE_TRACEBACK_ARGUMENTS = (
|
@@ -45,8 +48,10 @@ _EXCLUSIVE_TRACEBACK_ARGUMENTS = (
|
|
45
48
|
|
46
49
|
|
47
50
|
@d.dataclass(slots=True, repr=False, eq=False)
|
48
|
-
class console_rich_handler_t(
|
51
|
+
class console_rich_handler_t(l.Handler):
|
49
52
|
"""
|
53
|
+
kind: See logger_36.constant.handler.handler_codes_h.
|
54
|
+
|
50
55
|
alternating_lines:
|
51
56
|
- Initial value:
|
52
57
|
- 1: enabled for dark background
|
@@ -55,17 +60,19 @@ class console_rich_handler_t(lggg.Handler):
|
|
55
60
|
- Runtime value: 0/1=do not/do highlight next time.
|
56
61
|
"""
|
57
62
|
|
63
|
+
kind: h.ClassVar[str] = "c"
|
64
|
+
|
58
65
|
extension: handler_extension_t = d.field(init=False)
|
59
66
|
console: console_t = d.field(init=False)
|
60
|
-
MessageFromRecord:
|
67
|
+
MessageFromRecord: message_from_record_p = d.field(init=False)
|
61
68
|
alternating_lines: int = 0
|
62
69
|
background_is_light: bool = True
|
63
70
|
|
64
71
|
name: d.InitVar[str | None] = None
|
65
|
-
level: d.InitVar[int] =
|
72
|
+
level: d.InitVar[int] = l.NOTSET
|
66
73
|
should_store_memory_usage: d.InitVar[bool] = False
|
67
74
|
message_width: d.InitVar[int] = -1
|
68
|
-
formatter: d.InitVar[
|
75
|
+
formatter: d.InitVar[l.Formatter | None] = None
|
69
76
|
should_install_traceback: d.InitVar[bool] = False
|
70
77
|
should_record: d.InitVar[bool] = False
|
71
78
|
|
@@ -77,13 +84,13 @@ class console_rich_handler_t(lggg.Handler):
|
|
77
84
|
level: int,
|
78
85
|
should_store_memory_usage: bool,
|
79
86
|
message_width: int,
|
80
|
-
formatter:
|
87
|
+
formatter: l.Formatter | None,
|
81
88
|
should_install_traceback: bool,
|
82
89
|
should_record: bool,
|
83
90
|
rich_kwargs: dict[str, h.Any] | None,
|
84
91
|
) -> None:
|
85
92
|
""""""
|
86
|
-
|
93
|
+
l.Handler.__init__(self)
|
87
94
|
|
88
95
|
self.extension = handler_extension_t(
|
89
96
|
name=name,
|
@@ -127,7 +134,7 @@ class console_rich_handler_t(lggg.Handler):
|
|
127
134
|
else:
|
128
135
|
self.alternating_lines = -1
|
129
136
|
|
130
|
-
def emit(self, record:
|
137
|
+
def emit(self, record: l.LogRecord, /) -> None:
|
131
138
|
""""""
|
132
139
|
if hasattr(record, SHOW_W_RULE_ATTR):
|
133
140
|
richer = Rule(record.msg, DATE_TIME_COLOR)
|
@@ -5,7 +5,7 @@ SEE COPYRIGHT NOTICE BELOW
|
|
5
5
|
"""
|
6
6
|
|
7
7
|
import dataclasses as d
|
8
|
-
import logging as
|
8
|
+
import logging as l
|
9
9
|
import textwrap as txt_
|
10
10
|
import typing as h
|
11
11
|
from pathlib import Path as path_t
|
@@ -14,19 +14,25 @@ from logger_36.constant.message import LINE_INDENT
|
|
14
14
|
from logger_36.constant.record import SHOW_W_RULE_ATTR
|
15
15
|
from logger_36.task.format.rule import RuleAsText
|
16
16
|
from logger_36.type.handler import handler_extension_t
|
17
|
+
from logger_36.type.handler import message_from_record_raw_p as message_from_record_p
|
17
18
|
|
18
19
|
|
19
20
|
@d.dataclass(slots=True, repr=False, eq=False)
|
20
|
-
class file_handler_t(
|
21
|
+
class file_handler_t(l.FileHandler):
|
22
|
+
"""
|
23
|
+
kind: See logger_36.constant.handler.handler_codes_h.
|
24
|
+
"""
|
25
|
+
|
26
|
+
kind: h.ClassVar[str] = "f"
|
21
27
|
|
22
28
|
extension: handler_extension_t = d.field(init=False)
|
23
|
-
MessageFromRecord:
|
29
|
+
MessageFromRecord: message_from_record_p = d.field(init=False)
|
24
30
|
|
25
31
|
name: d.InitVar[str | None] = None
|
26
|
-
level: d.InitVar[int] =
|
32
|
+
level: d.InitVar[int] = l.NOTSET
|
27
33
|
should_store_memory_usage: d.InitVar[bool] = False
|
28
34
|
message_width: d.InitVar[int] = -1
|
29
|
-
formatter: d.InitVar[
|
35
|
+
formatter: d.InitVar[l.Formatter | None] = None
|
30
36
|
|
31
37
|
path: d.InitVar[path_t | None] = None
|
32
38
|
handler_args: d.InitVar[tuple[h.Any, ...] | None] = None
|
@@ -38,13 +44,13 @@ class file_handler_t(lggg.FileHandler):
|
|
38
44
|
level: int,
|
39
45
|
should_store_memory_usage: bool,
|
40
46
|
message_width: int,
|
41
|
-
formatter:
|
47
|
+
formatter: l.Formatter | None,
|
42
48
|
path: path_t | None,
|
43
49
|
handler_args: tuple[h.Any, ...] | None,
|
44
50
|
handler_kwargs: dict[str, h.Any] | None,
|
45
51
|
) -> None:
|
46
52
|
""""""
|
47
|
-
|
53
|
+
l.FileHandler.__init__(self, path, *handler_args, **handler_kwargs)
|
48
54
|
|
49
55
|
self.extension = handler_extension_t(
|
50
56
|
name=name,
|
@@ -57,7 +63,7 @@ class file_handler_t(lggg.FileHandler):
|
|
57
63
|
|
58
64
|
self.MessageFromRecord = self.extension.MessageFromRecord
|
59
65
|
|
60
|
-
def emit(self, record:
|
66
|
+
def emit(self, record: l.LogRecord, /) -> None:
|
61
67
|
""""""
|
62
68
|
if hasattr(record, SHOW_W_RULE_ATTR):
|
63
69
|
message = RuleAsText(record.msg)
|
@@ -5,22 +5,26 @@ SEE COPYRIGHT NOTICE BELOW
|
|
5
5
|
"""
|
6
6
|
|
7
7
|
import dataclasses as d
|
8
|
-
import logging as
|
8
|
+
import logging as l
|
9
9
|
import typing as h
|
10
10
|
|
11
|
-
|
11
|
+
from logger_36.catalog.config.optional import RICH_IS_AVAILABLE
|
12
|
+
|
13
|
+
if RICH_IS_AVAILABLE:
|
12
14
|
from logger_36.catalog.config.console_rich import DATE_TIME_COLOR
|
13
15
|
from logger_36.catalog.handler.console_rich import HighlightedVersion
|
14
16
|
from rich.console import Console as console_t # noqa
|
15
17
|
from rich.console import ConsoleOptions as console_options_t # noqa
|
16
18
|
from rich.markup import escape as EscapedForRich # noqa
|
17
19
|
from rich.terminal_theme import DEFAULT_TERMINAL_THEME # noqa
|
18
|
-
|
19
|
-
|
20
|
+
else:
|
21
|
+
DATE_TIME_COLOR = HighlightedVersion = console_t = console_options_t = (
|
22
|
+
EscapedForRich
|
23
|
+
) = DEFAULT_TERMINAL_THEME = None
|
20
24
|
|
21
25
|
from logger_36.constant.record import SHOW_W_RULE_ATTR
|
22
26
|
from logger_36.task.format.rule import Rule, RuleAsText
|
23
|
-
from logger_36.type.handler import handler_extension_t
|
27
|
+
from logger_36.type.handler import handler_extension_t, message_from_record_h
|
24
28
|
|
25
29
|
|
26
30
|
@h.runtime_checkable
|
@@ -34,8 +38,10 @@ class display_rule_p(h.Protocol):
|
|
34
38
|
|
35
39
|
|
36
40
|
@d.dataclass(slots=True, repr=False, eq=False)
|
37
|
-
class generic_handler_t(
|
41
|
+
class generic_handler_t(l.Handler):
|
38
42
|
"""
|
43
|
+
kind: See logger_36.constant.handler.handler_codes_h.
|
44
|
+
|
39
45
|
alternating_lines:
|
40
46
|
- Initial value:
|
41
47
|
- 1: enabled for dark background
|
@@ -54,6 +60,8 @@ class generic_handler_t(lggg.Handler):
|
|
54
60
|
it is indeed called at the end of the emit method.
|
55
61
|
"""
|
56
62
|
|
63
|
+
kind: h.ClassVar[str] = "g"
|
64
|
+
|
57
65
|
ShowMessage: show_message_p
|
58
66
|
# "None -> h.Any" (twice below) since None | None is invalid.
|
59
67
|
console: console_t | h.Any = None
|
@@ -63,13 +71,13 @@ class generic_handler_t(lggg.Handler):
|
|
63
71
|
|
64
72
|
DisplayRule: display_rule_p = d.field(init=False)
|
65
73
|
extension: handler_extension_t = d.field(init=False)
|
66
|
-
MessageFromRecord:
|
74
|
+
MessageFromRecord: message_from_record_h = d.field(init=False)
|
67
75
|
|
68
76
|
name: d.InitVar[str | None] = None
|
69
|
-
level: d.InitVar[int] =
|
77
|
+
level: d.InitVar[int] = l.NOTSET
|
70
78
|
should_store_memory_usage: d.InitVar[bool] = False
|
71
79
|
message_width: d.InitVar[int] = -1
|
72
|
-
formatter: d.InitVar[
|
80
|
+
formatter: d.InitVar[l.Formatter | None] = None
|
73
81
|
|
74
82
|
supports_html: d.InitVar[bool] = False
|
75
83
|
should_record: d.InitVar[bool] = False
|
@@ -81,13 +89,13 @@ class generic_handler_t(lggg.Handler):
|
|
81
89
|
level: int,
|
82
90
|
should_store_memory_usage: bool,
|
83
91
|
message_width: int,
|
84
|
-
formatter:
|
92
|
+
formatter: l.Formatter | None,
|
85
93
|
supports_html: bool,
|
86
94
|
should_record: bool,
|
87
95
|
rich_kwargs: dict[str, h.Any] | None,
|
88
96
|
) -> None:
|
89
97
|
""""""
|
90
|
-
|
98
|
+
l.Handler.__init__(self)
|
91
99
|
|
92
100
|
self.extension = handler_extension_t(
|
93
101
|
name=name,
|
@@ -124,7 +132,7 @@ class generic_handler_t(lggg.Handler):
|
|
124
132
|
else:
|
125
133
|
self.alternating_lines = -1
|
126
134
|
|
127
|
-
def emit(self, record:
|
135
|
+
def emit(self, record: l.LogRecord, /) -> None:
|
128
136
|
""""""
|
129
137
|
if self.console is None:
|
130
138
|
if hasattr(record, SHOW_W_RULE_ATTR):
|
@@ -4,12 +4,12 @@ Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
|
4
4
|
SEE COPYRIGHT NOTICE BELOW
|
5
5
|
"""
|
6
6
|
|
7
|
-
from logger_36.instance.logger import
|
7
|
+
from logger_36.instance.logger import L
|
8
8
|
from logger_36.task.measure.chronos import ElapsedTime
|
9
9
|
from logger_36.type.logger import logger_t
|
10
10
|
|
11
11
|
|
12
|
-
def LogElapsedTime(*, logger: logger_t =
|
12
|
+
def LogElapsedTime(*, logger: logger_t = L) -> None:
|
13
13
|
""""""
|
14
14
|
logger.info(f"Elapsed Time: {ElapsedTime()}")
|
15
15
|
|
logger_36/catalog/logger/gpu.py
CHANGED
@@ -4,29 +4,29 @@ Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
|
4
4
|
SEE COPYRIGHT NOTICE BELOW
|
5
5
|
"""
|
6
6
|
|
7
|
-
import sys as
|
7
|
+
import sys as s
|
8
8
|
|
9
9
|
from logger_36.constant.error import GPU_LOGGING_ERROR
|
10
|
-
from logger_36.instance.logger import
|
10
|
+
from logger_36.instance.logger import L
|
11
11
|
from logger_36.type.logger import logger_t
|
12
12
|
|
13
13
|
try:
|
14
14
|
import tensorflow as tsfl # noqa
|
15
15
|
import tensorrt as tsrt # noqa
|
16
|
-
|
17
|
-
_GPU_LOGGING_ERROR = None
|
18
16
|
except ModuleNotFoundError:
|
19
17
|
tsfl = tsrt = None
|
20
18
|
_GPU_LOGGING_ERROR = GPU_LOGGING_ERROR
|
19
|
+
else:
|
20
|
+
_GPU_LOGGING_ERROR = None
|
21
21
|
|
22
22
|
|
23
|
-
def LogGPURelatedDetails(*, logger: logger_t =
|
23
|
+
def LogGPURelatedDetails(*, logger: logger_t = L) -> None:
|
24
24
|
""""""
|
25
25
|
global _GPU_LOGGING_ERROR
|
26
26
|
|
27
27
|
if None in (tsfl, tsrt):
|
28
28
|
if _GPU_LOGGING_ERROR is not None:
|
29
|
-
print(_GPU_LOGGING_ERROR, file=
|
29
|
+
print(_GPU_LOGGING_ERROR, file=s.stderr)
|
30
30
|
_GPU_LOGGING_ERROR = None
|
31
31
|
return
|
32
32
|
|
@@ -6,7 +6,7 @@ SEE COPYRIGHT NOTICE BELOW
|
|
6
6
|
|
7
7
|
from logger_36.config.memory import LENGTH_100, MAX_N_SAMPLES
|
8
8
|
from logger_36.constant.memory import storage_units_h
|
9
|
-
from logger_36.instance.logger import
|
9
|
+
from logger_36.instance.logger import L
|
10
10
|
from logger_36.task.format.memory import FormattedUsage, UsageBar
|
11
11
|
from logger_36.task.format.message import MessageWithActualExpected
|
12
12
|
from logger_36.type.logger import logger_t
|
@@ -18,7 +18,7 @@ def LogMemoryUsages(
|
|
18
18
|
decimals: int = None,
|
19
19
|
max_n_samples: int | None = MAX_N_SAMPLES,
|
20
20
|
length_100: int = LENGTH_100,
|
21
|
-
logger: logger_t =
|
21
|
+
logger: logger_t = L,
|
22
22
|
) -> None:
|
23
23
|
""""""
|
24
24
|
if not logger.any_handler_stores_memory:
|
@@ -71,7 +71,7 @@ def LogMaximumMemoryUsage(
|
|
71
71
|
*,
|
72
72
|
unit: storage_units_h | None = "a",
|
73
73
|
decimals: int | None = None,
|
74
|
-
logger: logger_t =
|
74
|
+
logger: logger_t = L,
|
75
75
|
) -> None:
|
76
76
|
"""
|
77
77
|
unit: b or None=bytes, k=kilo, m=mega, g=giga, a=auto
|
@@ -5,7 +5,7 @@ SEE COPYRIGHT NOTICE BELOW
|
|
5
5
|
"""
|
6
6
|
|
7
7
|
from logger_36.constant.system import MAX_DETAIL_NAME_LENGTH, SYSTEM_DETAILS_AS_DICT
|
8
|
-
from logger_36.instance.logger import
|
8
|
+
from logger_36.instance.logger import L
|
9
9
|
from logger_36.task.inspection import Modules
|
10
10
|
from logger_36.type.logger import logger_t
|
11
11
|
|
@@ -15,7 +15,7 @@ def LogSystemDetails(
|
|
15
15
|
modules_with_version: bool = True,
|
16
16
|
modules_formatted: bool = True,
|
17
17
|
should_restrict_modules_to_loaded: bool = True,
|
18
|
-
logger: logger_t =
|
18
|
+
logger: logger_t = L,
|
19
19
|
) -> None:
|
20
20
|
""""""
|
21
21
|
details = "\n".join(
|
logger_36/constant/error.py
CHANGED
@@ -16,7 +16,7 @@ MEMORY_MEASURE_ERROR = (
|
|
16
16
|
"is not installed or not importable."
|
17
17
|
)
|
18
18
|
|
19
|
-
|
19
|
+
MISSING_RICH_MESSAGE = (
|
20
20
|
"The Rich console handler is not available because the Rich package "
|
21
21
|
"(https://rich.readthedocs.io/en/stable/) "
|
22
22
|
"is not installed or not importable. "
|
logger_36/constant/handler.py
CHANGED
@@ -6,8 +6,8 @@ SEE COPYRIGHT NOTICE BELOW
|
|
6
6
|
|
7
7
|
import typing as h
|
8
8
|
|
9
|
-
handler_codes_h = h.Literal["g", "c", "f", "a"]
|
10
|
-
|
9
|
+
handler_codes_h = h.Literal["g", "c", "f", "a"] # g=generic, c=console, f=file, a=all.
|
10
|
+
HANDLER_KINDS: tuple[str, ...] = h.get_args(handler_codes_h)
|
11
11
|
|
12
12
|
ANONYMOUS = "<Anonymous>"
|
13
13
|
|
logger_36/constant/logger.py
CHANGED
@@ -4,21 +4,14 @@ Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
|
4
4
|
SEE COPYRIGHT NOTICE BELOW
|
5
5
|
"""
|
6
6
|
|
7
|
-
import
|
8
|
-
import re as regx
|
9
|
-
import typing as h
|
7
|
+
import re as r
|
10
8
|
|
11
9
|
LOGGER_NAME = "logger-36"
|
12
10
|
|
13
11
|
# https://docs.python.org/3/library/logging.html#logging.captureWarnings
|
14
12
|
WARNING_LOGGER_NAME = "py.warnings"
|
15
13
|
WARNING_TYPE_PATTERN = r"\s*([^:]+):([0-9]+):\s*([^:]+)\s*:((.|\n)*)"
|
16
|
-
WARNING_TYPE_COMPILED_PATTERN =
|
17
|
-
|
18
|
-
# Second version: with self as first parameter.
|
19
|
-
logger_handle_h = (
|
20
|
-
h.Callable[[lggg.LogRecord], None] | h.Callable[[lggg.Logger, lggg.LogRecord], None]
|
21
|
-
)
|
14
|
+
WARNING_TYPE_COMPILED_PATTERN = r.compile(WARNING_TYPE_PATTERN)
|
22
15
|
|
23
16
|
"""
|
24
17
|
COPYRIGHT NOTICE
|
logger_36/content.py
CHANGED
@@ -4,9 +4,9 @@ Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
|
4
4
|
SEE COPYRIGHT NOTICE BELOW
|
5
5
|
"""
|
6
6
|
|
7
|
-
from logger_36.constant.message import LINE_INDENT
|
8
|
-
from logger_36.task.format.message import MessageWithActualExpected
|
9
|
-
from logger_36.task.format.rule import Rule, RuleAsText
|
7
|
+
from logger_36.constant.message import LINE_INDENT # noqa
|
8
|
+
from logger_36.task.format.message import MessageWithActualExpected # noqa
|
9
|
+
from logger_36.task.format.rule import Rule, RuleAsText # noqa
|
10
10
|
|
11
11
|
"""
|
12
12
|
COPYRIGHT NOTICE
|