logger-36 2025.16__py3-none-any.whl → 2025.18__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 +1 -15
- logger_36/api/content.py +1 -15
- logger_36/api/gpu.py +1 -15
- logger_36/api/memory.py +1 -15
- logger_36/api/storage.py +1 -15
- logger_36/api/system.py +1 -15
- logger_36/api/time.py +1 -15
- logger_36/api/type.py +1 -15
- logger_36/catalog/config/console_rich.py +1 -15
- logger_36/catalog/config/optional.py +1 -15
- logger_36/catalog/handler/console.py +4 -21
- logger_36/catalog/handler/console_rich.py +6 -34
- logger_36/catalog/handler/file.py +5 -24
- logger_36/catalog/handler/generic.py +17 -58
- logger_36/catalog/logger/chronos.py +1 -15
- logger_36/catalog/logger/gpu.py +1 -15
- logger_36/catalog/logger/memory.py +8 -20
- logger_36/catalog/logger/system.py +1 -15
- logger_36/config/issue.py +1 -15
- logger_36/config/memory.py +1 -15
- logger_36/config/message.py +1 -15
- logger_36/config/system.py +1 -15
- logger_36/constant/error.py +1 -15
- logger_36/constant/generic.py +1 -15
- logger_36/constant/html.py +1 -15
- logger_36/constant/issue.py +1 -15
- logger_36/constant/logger.py +1 -15
- logger_36/constant/memory.py +1 -15
- logger_36/constant/message.py +1 -15
- logger_36/constant/path.py +4 -18
- logger_36/constant/record.py +2 -17
- logger_36/constant/system.py +1 -15
- logger_36/extension/html_.py +1 -15
- logger_36/extension/line.py +1 -15
- logger_36/instance/logger.py +3 -16
- logger_36/instance/loggers.py +1 -15
- logger_36/task/format/memory.py +1 -15
- logger_36/task/format/message.py +1 -15
- logger_36/task/format/rule.py +1 -15
- logger_36/task/inspection.py +1 -15
- logger_36/task/measure/chronos.py +1 -15
- logger_36/task/measure/memory.py +1 -15
- logger_36/task/storage.py +1 -15
- logger_36/type/handler.py +10 -57
- logger_36/type/issue.py +1 -15
- logger_36/type/logger.py +50 -93
- logger_36/type/loggers.py +2 -17
- logger_36/type/message.py +1 -15
- logger_36/version.py +2 -16
- {logger_36-2025.16.dist-info → logger_36-2025.18.dist-info}/METADATA +2 -2
- logger_36-2025.18.dist-info/RECORD +53 -0
- logger_36/constant/handler.py +0 -58
- logger_36-2025.16.dist-info/RECORD +0 -54
- {logger_36-2025.16.dist-info → logger_36-2025.18.dist-info}/WHEEL +0 -0
- {logger_36-2025.16.dist-info → logger_36-2025.18.dist-info}/top_level.txt +0 -0
logger_36/task/format/rule.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
"""
|
2
|
-
Copyright CNRS/
|
2
|
+
Copyright CNRS (https://www.cnrs.fr/index.php/en)
|
3
3
|
Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
4
4
|
SEE COPYRIGHT NOTICE BELOW
|
5
5
|
"""
|
@@ -60,18 +60,4 @@ The fact that you are presently reading this means that you have had
|
|
60
60
|
knowledge of the CeCILL license and that you accept its terms.
|
61
61
|
|
62
62
|
SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
|
63
|
-
|
64
|
-
This software is being developed by Eric Debreuve, a CNRS employee and
|
65
|
-
member of team Morpheme.
|
66
|
-
Team Morpheme is a joint team between Inria, CNRS, and UniCA.
|
67
|
-
It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
|
68
|
-
I3S, and Laboratory iBV.
|
69
|
-
|
70
|
-
CNRS: https://www.cnrs.fr/index.php/en
|
71
|
-
Inria: https://www.inria.fr/en/
|
72
|
-
UniCA: https://univ-cotedazur.eu/
|
73
|
-
Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
|
74
|
-
I3S: https://www.i3s.unice.fr/en/
|
75
|
-
iBV: http://ibv.unice.fr/
|
76
|
-
Team Morpheme: https://team.inria.fr/morpheme/
|
77
63
|
"""
|
logger_36/task/inspection.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
"""
|
2
|
-
Copyright CNRS/
|
2
|
+
Copyright CNRS (https://www.cnrs.fr/index.php/en)
|
3
3
|
Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
4
4
|
SEE COPYRIGHT NOTICE BELOW
|
5
5
|
"""
|
@@ -132,18 +132,4 @@ The fact that you are presently reading this means that you have had
|
|
132
132
|
knowledge of the CeCILL license and that you accept its terms.
|
133
133
|
|
134
134
|
SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
|
135
|
-
|
136
|
-
This software is being developed by Eric Debreuve, a CNRS employee and
|
137
|
-
member of team Morpheme.
|
138
|
-
Team Morpheme is a joint team between Inria, CNRS, and UniCA.
|
139
|
-
It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
|
140
|
-
I3S, and Laboratory iBV.
|
141
|
-
|
142
|
-
CNRS: https://www.cnrs.fr/index.php/en
|
143
|
-
Inria: https://www.inria.fr/en/
|
144
|
-
UniCA: https://univ-cotedazur.eu/
|
145
|
-
Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
|
146
|
-
I3S: https://www.i3s.unice.fr/en/
|
147
|
-
iBV: http://ibv.unice.fr/
|
148
|
-
Team Morpheme: https://team.inria.fr/morpheme/
|
149
135
|
"""
|
@@ -1,5 +1,5 @@
|
|
1
1
|
"""
|
2
|
-
Copyright CNRS/
|
2
|
+
Copyright CNRS (https://www.cnrs.fr/index.php/en)
|
3
3
|
Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
4
4
|
SEE COPYRIGHT NOTICE BELOW
|
5
5
|
"""
|
@@ -65,18 +65,4 @@ The fact that you are presently reading this means that you have had
|
|
65
65
|
knowledge of the CeCILL license and that you accept its terms.
|
66
66
|
|
67
67
|
SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
|
68
|
-
|
69
|
-
This software is being developed by Eric Debreuve, a CNRS employee and
|
70
|
-
member of team Morpheme.
|
71
|
-
Team Morpheme is a joint team between Inria, CNRS, and UniCA.
|
72
|
-
It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
|
73
|
-
I3S, and Laboratory iBV.
|
74
|
-
|
75
|
-
CNRS: https://www.cnrs.fr/index.php/en
|
76
|
-
Inria: https://www.inria.fr/en/
|
77
|
-
UniCA: https://univ-cotedazur.eu/
|
78
|
-
Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
|
79
|
-
I3S: https://www.i3s.unice.fr/en/
|
80
|
-
iBV: http://ibv.unice.fr/
|
81
|
-
Team Morpheme: https://team.inria.fr/morpheme/
|
82
68
|
"""
|
logger_36/task/measure/memory.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
"""
|
2
|
-
Copyright CNRS/
|
2
|
+
Copyright CNRS (https://www.cnrs.fr/index.php/en)
|
3
3
|
Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
4
4
|
SEE COPYRIGHT NOTICE BELOW
|
5
5
|
"""
|
@@ -55,18 +55,4 @@ The fact that you are presently reading this means that you have had
|
|
55
55
|
knowledge of the CeCILL license and that you accept its terms.
|
56
56
|
|
57
57
|
SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
|
58
|
-
|
59
|
-
This software is being developed by Eric Debreuve, a CNRS employee and
|
60
|
-
member of team Morpheme.
|
61
|
-
Team Morpheme is a joint team between Inria, CNRS, and UniCA.
|
62
|
-
It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
|
63
|
-
I3S, and Laboratory iBV.
|
64
|
-
|
65
|
-
CNRS: https://www.cnrs.fr/index.php/en
|
66
|
-
Inria: https://www.inria.fr/en/
|
67
|
-
UniCA: https://univ-cotedazur.eu/
|
68
|
-
Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
|
69
|
-
I3S: https://www.i3s.unice.fr/en/
|
70
|
-
iBV: http://ibv.unice.fr/
|
71
|
-
Team Morpheme: https://team.inria.fr/morpheme/
|
72
58
|
"""
|
logger_36/task/storage.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
"""
|
2
|
-
Copyright CNRS/
|
2
|
+
Copyright CNRS (https://www.cnrs.fr/index.php/en)
|
3
3
|
Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
4
4
|
SEE COPYRIGHT NOTICE BELOW
|
5
5
|
"""
|
@@ -101,18 +101,4 @@ The fact that you are presently reading this means that you have had
|
|
101
101
|
knowledge of the CeCILL license and that you accept its terms.
|
102
102
|
|
103
103
|
SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
|
104
|
-
|
105
|
-
This software is being developed by Eric Debreuve, a CNRS employee and
|
106
|
-
member of team Morpheme.
|
107
|
-
Team Morpheme is a joint team between Inria, CNRS, and UniCA.
|
108
|
-
It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
|
109
|
-
I3S, and Laboratory iBV.
|
110
|
-
|
111
|
-
CNRS: https://www.cnrs.fr/index.php/en
|
112
|
-
Inria: https://www.inria.fr/en/
|
113
|
-
UniCA: https://univ-cotedazur.eu/
|
114
|
-
Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
|
115
|
-
I3S: https://www.i3s.unice.fr/en/
|
116
|
-
iBV: http://ibv.unice.fr/
|
117
|
-
Team Morpheme: https://team.inria.fr/morpheme/
|
118
104
|
"""
|
logger_36/type/handler.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
"""
|
2
|
-
Copyright CNRS/
|
2
|
+
Copyright CNRS (https://www.cnrs.fr/index.php/en)
|
3
3
|
Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
4
4
|
SEE COPYRIGHT NOTICE BELOW
|
5
5
|
"""
|
@@ -10,26 +10,15 @@ import typing as h
|
|
10
10
|
from pathlib import Path as path_t
|
11
11
|
|
12
12
|
from logger_36.config.message import FALLBACK_MESSAGE_WIDTH
|
13
|
-
from logger_36.
|
14
|
-
from logger_36.constant.handler import HANDLER_KINDS
|
15
|
-
from logger_36.task.format.message import MessageFromRecord, MessageWithActualExpected
|
13
|
+
from logger_36.task.format.message import MessageFromRecord
|
16
14
|
from logger_36.task.format.rule import RuleAsText
|
17
|
-
from logger_36.task.measure.chronos import TimeStamp
|
18
|
-
from logger_36.task.measure.memory import CanCheckUsage as CanCheckMemoryUsage
|
19
15
|
from logger_36.type.message import MessageFromRecord_h, RuleWithText_h
|
20
16
|
|
21
|
-
_MEMORY_MEASURE_ERROR = MEMORY_MEASURE_ERROR
|
22
|
-
|
23
17
|
|
24
18
|
class _base_t:
|
25
|
-
|
26
|
-
|
27
|
-
def __init__(
|
28
|
-
self, name: str | None, should_store_memory_usage: bool, message_width: int
|
29
|
-
) -> None:
|
19
|
+
def __init__(self, name: str | None, message_width: int) -> None:
|
30
20
|
""""""
|
31
21
|
self.name = name
|
32
|
-
self.should_store_memory_usage = should_store_memory_usage
|
33
22
|
self.message_width = message_width
|
34
23
|
#
|
35
24
|
self.MessageFromRecord: MessageFromRecord_h | None = None
|
@@ -38,25 +27,8 @@ class _base_t:
|
|
38
27
|
|
39
28
|
def __post_init__(self) -> None:
|
40
29
|
""""""
|
41
|
-
global _MEMORY_MEASURE_ERROR
|
42
|
-
|
43
|
-
if self.name in HANDLER_KINDS:
|
44
|
-
raise ValueError(
|
45
|
-
MessageWithActualExpected(
|
46
|
-
"Invalid handler name",
|
47
|
-
actual=self.name,
|
48
|
-
expected=f"a name not in {str(HANDLER_KINDS)[1:-1]}",
|
49
|
-
)
|
50
|
-
)
|
51
|
-
|
52
30
|
if self.name is None:
|
53
|
-
self.name =
|
54
|
-
|
55
|
-
if self.should_store_memory_usage and not CanCheckMemoryUsage():
|
56
|
-
self.should_store_memory_usage = False
|
57
|
-
if _MEMORY_MEASURE_ERROR is not None:
|
58
|
-
s.__stderr__.write(_MEMORY_MEASURE_ERROR + "\n")
|
59
|
-
_MEMORY_MEASURE_ERROR = None
|
31
|
+
self.name = f"{type(self).__name__}:{hex(id(self))[2:]}"
|
60
32
|
|
61
33
|
if 0 < self.message_width < FALLBACK_MESSAGE_WIDTH:
|
62
34
|
self.message_width = FALLBACK_MESSAGE_WIDTH
|
@@ -68,23 +40,19 @@ class _base_t:
|
|
68
40
|
"""
|
69
41
|
raise NotImplementedError
|
70
42
|
|
71
|
-
def
|
72
|
-
"""
|
73
|
-
See documentation of
|
74
|
-
logger_36.catalog.handler.generic.generic_handler_t.LogAsIs.
|
75
|
-
"""
|
43
|
+
def EmitAsIs(self, message: str, /) -> None:
|
44
|
+
""""""
|
76
45
|
s.__stdout__.write(message + "\n")
|
77
46
|
|
78
|
-
def
|
47
|
+
def EmitRule(self, /, *, text: str | None = None, color: str = "black") -> None:
|
79
48
|
""""""
|
80
|
-
self.
|
49
|
+
self.EmitAsIs(RuleAsText(text, None))
|
81
50
|
|
82
51
|
|
83
52
|
class handler_t(l.Handler, _base_t):
|
84
53
|
def __init__(
|
85
54
|
self,
|
86
55
|
name: str | None,
|
87
|
-
should_store_memory_usage: bool,
|
88
56
|
message_width: int,
|
89
57
|
level: int,
|
90
58
|
formatter: l.Formatter | None,
|
@@ -92,7 +60,7 @@ class handler_t(l.Handler, _base_t):
|
|
92
60
|
) -> None:
|
93
61
|
""""""
|
94
62
|
l.Handler.__init__(self)
|
95
|
-
_base_t.__init__(self, name,
|
63
|
+
_base_t.__init__(self, name, message_width)
|
96
64
|
__post_init__(self, level, formatter)
|
97
65
|
|
98
66
|
|
@@ -100,7 +68,6 @@ class file_handler_t(l.FileHandler, _base_t):
|
|
100
68
|
def __init__(
|
101
69
|
self,
|
102
70
|
name: str | None,
|
103
|
-
should_store_memory_usage: bool,
|
104
71
|
message_width: int,
|
105
72
|
level: int,
|
106
73
|
formatter: l.Formatter | None,
|
@@ -116,7 +83,7 @@ class file_handler_t(l.FileHandler, _base_t):
|
|
116
83
|
raise ValueError(f"File or folder already exists: {path}.")
|
117
84
|
|
118
85
|
l.FileHandler.__init__(self, path)
|
119
|
-
_base_t.__init__(self, name,
|
86
|
+
_base_t.__init__(self, name, message_width)
|
120
87
|
__post_init__(self, level, formatter)
|
121
88
|
|
122
89
|
|
@@ -179,18 +146,4 @@ The fact that you are presently reading this means that you have had
|
|
179
146
|
knowledge of the CeCILL license and that you accept its terms.
|
180
147
|
|
181
148
|
SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
|
182
|
-
|
183
|
-
This software is being developed by Eric Debreuve, a CNRS employee and
|
184
|
-
member of team Morpheme.
|
185
|
-
Team Morpheme is a joint team between Inria, CNRS, and UniCA.
|
186
|
-
It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
|
187
|
-
I3S, and Laboratory iBV.
|
188
|
-
|
189
|
-
CNRS: https://www.cnrs.fr/index.php/en
|
190
|
-
Inria: https://www.inria.fr/en/
|
191
|
-
UniCA: https://univ-cotedazur.eu/
|
192
|
-
Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
|
193
|
-
I3S: https://www.i3s.unice.fr/en/
|
194
|
-
iBV: http://ibv.unice.fr/
|
195
|
-
Team Morpheme: https://team.inria.fr/morpheme/
|
196
149
|
"""
|
logger_36/type/issue.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
"""
|
2
|
-
Copyright CNRS/
|
2
|
+
Copyright CNRS (https://www.cnrs.fr/index.php/en)
|
3
3
|
Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
4
4
|
SEE COPYRIGHT NOTICE BELOW
|
5
5
|
"""
|
@@ -74,18 +74,4 @@ The fact that you are presently reading this means that you have had
|
|
74
74
|
knowledge of the CeCILL license and that you accept its terms.
|
75
75
|
|
76
76
|
SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
|
77
|
-
|
78
|
-
This software is being developed by Eric Debreuve, a CNRS employee and
|
79
|
-
member of team Morpheme.
|
80
|
-
Team Morpheme is a joint team between Inria, CNRS, and UniCA.
|
81
|
-
It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
|
82
|
-
I3S, and Laboratory iBV.
|
83
|
-
|
84
|
-
CNRS: https://www.cnrs.fr/index.php/en
|
85
|
-
Inria: https://www.inria.fr/en/
|
86
|
-
UniCA: https://univ-cotedazur.eu/
|
87
|
-
Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
|
88
|
-
I3S: https://www.i3s.unice.fr/en/
|
89
|
-
iBV: http://ibv.unice.fr/
|
90
|
-
Team Morpheme: https://team.inria.fr/morpheme/
|
91
77
|
"""
|
logger_36/type/logger.py
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
"""
|
2
|
-
Copyright CNRS/
|
2
|
+
Copyright CNRS (https://www.cnrs.fr/index.php/en)
|
3
3
|
Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
4
4
|
SEE COPYRIGHT NOTICE BELOW
|
5
5
|
"""
|
6
6
|
|
7
7
|
import dataclasses as d
|
8
|
+
import inspect as e
|
8
9
|
import logging as l
|
9
10
|
import sys as s
|
10
11
|
import textwrap as text
|
@@ -27,26 +28,20 @@ from logger_36.config.message import (
|
|
27
28
|
ELAPSED_TIME_SEPARATOR,
|
28
29
|
LONG_ENOUGH,
|
29
30
|
TIME_FORMAT,
|
31
|
+
WHERE_SEPARATOR,
|
30
32
|
)
|
33
|
+
from logger_36.constant.error import MEMORY_MEASURE_ERROR
|
31
34
|
from logger_36.constant.generic import NOT_PASSED
|
32
|
-
from logger_36.constant.handler import ANONYMOUS, HANDLER_KINDS, handler_codes_h
|
33
35
|
from logger_36.constant.issue import ISSUE_LEVEL_SEPARATOR, ORDER, order_h
|
34
|
-
from logger_36.constant.logger import
|
35
|
-
LOGGER_NAME,
|
36
|
-
WARNING_LOGGER_NAME,
|
37
|
-
WARNING_TYPE_COMPILED_PATTERN,
|
38
|
-
)
|
36
|
+
from logger_36.constant.logger import WARNING_LOGGER_NAME, WARNING_TYPE_COMPILED_PATTERN
|
39
37
|
from logger_36.constant.memory import UNKNOWN_MEMORY_USAGE
|
40
38
|
from logger_36.constant.message import LINE_INDENT, TIME_LENGTH_m_1, expected_op_h
|
41
|
-
from logger_36.constant.path import PROJECT_FILE_RELATIVE
|
42
|
-
from logger_36.constant.record import
|
43
|
-
HIDE_WHERE_ATTR,
|
44
|
-
SHOW_W_RULE_ATTR,
|
45
|
-
STORE_MEMORY_ATTR,
|
46
|
-
)
|
39
|
+
from logger_36.constant.path import PROJECT_FILE_RELATIVE, USER_FOLDER
|
40
|
+
from logger_36.constant.record import SHOW_W_RULE_ATTR, SHOW_WHERE_ATTR
|
47
41
|
from logger_36.task.format.message import MessageFromRecord, MessageWithActualExpected
|
48
42
|
from logger_36.task.format.rule import RuleAsText
|
49
43
|
from logger_36.task.measure.chronos import ElapsedTime
|
44
|
+
from logger_36.task.measure.memory import CanCheckUsage as CanCheckMemoryUsage
|
50
45
|
from logger_36.task.measure.memory import CurrentUsage as CurrentMemoryUsage
|
51
46
|
from logger_36.type.handler import any_handler_t as base_handler_t
|
52
47
|
from logger_36.type.issue import NewIssue, issue_t
|
@@ -66,6 +61,7 @@ logger_handle_h = logger_handle_raw_h | logger_handle_with_self_h
|
|
66
61
|
|
67
62
|
_DATE_TIME_ORIGIN = date_time_t.fromtimestamp(1970, None)
|
68
63
|
_DATE_ORIGIN = _DATE_TIME_ORIGIN.date()
|
64
|
+
_MEMORY_MEASURE_ERROR = MEMORY_MEASURE_ERROR
|
69
65
|
|
70
66
|
|
71
67
|
@d.dataclass(slots=True, repr=False, eq=False)
|
@@ -85,6 +81,7 @@ class logger_t(base_t):
|
|
85
81
|
"""
|
86
82
|
|
87
83
|
should_record_messages: bool = False
|
84
|
+
should_watch_memory_usage: bool = False
|
88
85
|
exit_on_error: bool = False # Implies exit_on_critical.
|
89
86
|
exit_on_critical: bool = False
|
90
87
|
|
@@ -93,7 +90,6 @@ class logger_t(base_t):
|
|
93
90
|
|
94
91
|
last_message_now: date_time_t = d.field(init=False, default=_DATE_TIME_ORIGIN)
|
95
92
|
last_message_date: date_t = d.field(init=False, default=_DATE_ORIGIN)
|
96
|
-
any_handler_stores_memory: bool = d.field(init=False, default=False)
|
97
93
|
memory_usages: list[tuple[str, int]] = d.field(init=False, default_factory=list)
|
98
94
|
context_levels: list[str] = d.field(init=False, default_factory=list)
|
99
95
|
staged_issues: list[issue_t] = d.field(init=False, default_factory=list)
|
@@ -106,7 +102,7 @@ class logger_t(base_t):
|
|
106
102
|
_should_hold_messages: bool = d.field(init=False, default=True)
|
107
103
|
_should_activate_log_interceptions: bool = d.field(init=False, default=False)
|
108
104
|
|
109
|
-
name_: d.InitVar[str] =
|
105
|
+
name_: d.InitVar[str | None] = None
|
110
106
|
level_: d.InitVar[int] = l.NOTSET
|
111
107
|
activate_wrn_interceptions: d.InitVar[bool] = True
|
112
108
|
activate_log_interceptions: d.InitVar[bool] = True
|
@@ -152,13 +148,18 @@ class logger_t(base_t):
|
|
152
148
|
|
153
149
|
def __post_init__(
|
154
150
|
self,
|
155
|
-
name_: str,
|
151
|
+
name_: str | None,
|
156
152
|
level_: int,
|
157
153
|
activate_wrn_interceptions: bool,
|
158
154
|
activate_log_interceptions: bool,
|
159
155
|
activate_exc_interceptions: bool,
|
160
156
|
) -> None:
|
161
157
|
""""""
|
158
|
+
global _MEMORY_MEASURE_ERROR
|
159
|
+
|
160
|
+
if name_ is None:
|
161
|
+
name_ = f"{type(self).__name__}:{hex(id(self))[2:]}"
|
162
|
+
|
162
163
|
base_t.__init__(self, name_)
|
163
164
|
self.setLevel(level_)
|
164
165
|
self.propagate = False # Part of base_t.
|
@@ -166,8 +167,6 @@ class logger_t(base_t):
|
|
166
167
|
for level in l.getLevelNamesMapping().values():
|
167
168
|
self.events[level] = 0
|
168
169
|
|
169
|
-
self.info(f'New logger "{self.name}" for "{PROJECT_FILE_RELATIVE}"')
|
170
|
-
|
171
170
|
if activate_wrn_interceptions:
|
172
171
|
self.ToggleWarningInterceptions(True)
|
173
172
|
if activate_log_interceptions:
|
@@ -178,6 +177,14 @@ class logger_t(base_t):
|
|
178
177
|
if self.exit_on_error:
|
179
178
|
self.exit_on_critical = True
|
180
179
|
|
180
|
+
if self.should_watch_memory_usage and not CanCheckMemoryUsage():
|
181
|
+
self.should_watch_memory_usage = False
|
182
|
+
if _MEMORY_MEASURE_ERROR is not None:
|
183
|
+
s.__stderr__.write(_MEMORY_MEASURE_ERROR + "\n")
|
184
|
+
_MEMORY_MEASURE_ERROR = None
|
185
|
+
|
186
|
+
self.info(f'New logger "{self.name}" for "{PROJECT_FILE_RELATIVE}"')
|
187
|
+
|
181
188
|
def handle(self, record: l.LogRecord, /) -> None:
|
182
189
|
""""""
|
183
190
|
elapsed_time, now = ElapsedTime(should_return_now=True)
|
@@ -193,11 +200,10 @@ class logger_t(base_t):
|
|
193
200
|
|
194
201
|
if (date := now.date()) != self.last_message_date:
|
195
202
|
self.last_message_date = date
|
196
|
-
# levelno: Added for management by logging.Logger.handle.
|
197
203
|
date_record = l.makeLogRecord(
|
198
204
|
{
|
199
205
|
"name": self.name,
|
200
|
-
"levelno": l.INFO,
|
206
|
+
"levelno": l.INFO, # For management by logging.Logger.handle.
|
201
207
|
"msg": f"DATE: {date.strftime(DATE_FORMAT)}",
|
202
208
|
SHOW_W_RULE_ATTR: True,
|
203
209
|
}
|
@@ -216,20 +222,15 @@ class logger_t(base_t):
|
|
216
222
|
|
217
223
|
# When.
|
218
224
|
if now - self.last_message_now > LONG_ENOUGH:
|
219
|
-
|
225
|
+
w_or_e = now.strftime(TIME_FORMAT)
|
220
226
|
else:
|
221
|
-
|
222
|
-
|
223
|
-
)
|
227
|
+
w_or_e = f"{ELAPSED_TIME_SEPARATOR}{elapsed_time:.<{TIME_LENGTH_m_1}}"
|
228
|
+
record.when_or_elapsed = w_or_e
|
224
229
|
self.last_message_now = now
|
225
230
|
|
226
231
|
# Where.
|
227
|
-
|
228
|
-
|
229
|
-
should_show_where = (record.levelno != l.INFO) and not hasattr(
|
230
|
-
record, HIDE_WHERE_ATTR
|
231
|
-
)
|
232
|
-
if should_store_where or should_show_where:
|
232
|
+
should_show_where = getattr(record, SHOW_WHERE_ATTR, record.levelno != l.INFO)
|
233
|
+
if should_show_where or self.should_watch_memory_usage:
|
233
234
|
module = path_t(record.pathname)
|
234
235
|
for path in s.path:
|
235
236
|
if module.is_relative_to(path):
|
@@ -237,7 +238,8 @@ class logger_t(base_t):
|
|
237
238
|
module = str(module).replace(FOLDER_SEPARATOR, ".")
|
238
239
|
break
|
239
240
|
else:
|
240
|
-
module
|
241
|
+
if module.is_relative_to(USER_FOLDER):
|
242
|
+
module = module.relative_to(USER_FOLDER)
|
241
243
|
where = f"{module}:{record.funcName}:{record.lineno}"
|
242
244
|
if should_show_where:
|
243
245
|
record.where = where
|
@@ -269,36 +271,9 @@ class logger_t(base_t):
|
|
269
271
|
|
270
272
|
self.events[record.levelno] += 1
|
271
273
|
|
272
|
-
if
|
274
|
+
if self.should_watch_memory_usage:
|
273
275
|
self.memory_usages.append((where, CurrentMemoryUsage()))
|
274
276
|
|
275
|
-
def SetLevel(self, level: int, /, *, which: handler_codes_h | str = "a") -> None:
|
276
|
-
"""
|
277
|
-
Set level of handlers, but the logger level is not modified.
|
278
|
-
|
279
|
-
which: if not a handler_codes_h, then it corresponds to a handler name.
|
280
|
-
"""
|
281
|
-
found = False
|
282
|
-
for handler in self.handlers:
|
283
|
-
if (
|
284
|
-
(which == "a")
|
285
|
-
or ((which in "cfg") and (getattr(handler, "kind", None) == which))
|
286
|
-
or (which == handler.name)
|
287
|
-
):
|
288
|
-
handler.setLevel(level)
|
289
|
-
if which not in HANDLER_KINDS:
|
290
|
-
return
|
291
|
-
found = True
|
292
|
-
|
293
|
-
if not found:
|
294
|
-
raise ValueError(
|
295
|
-
MessageWithActualExpected(
|
296
|
-
"Handler not found",
|
297
|
-
actual=which,
|
298
|
-
expected=f"{str(HANDLER_KINDS)[1:-1]}, or a handler name",
|
299
|
-
)
|
300
|
-
)
|
301
|
-
|
302
277
|
def MakeMonochrome(self) -> None:
|
303
278
|
""""""
|
304
279
|
self.AddHandler(console_handler_t)
|
@@ -417,7 +392,6 @@ class logger_t(base_t):
|
|
417
392
|
*,
|
418
393
|
name: str | None = None,
|
419
394
|
level: int = l.INFO,
|
420
|
-
should_store_memory_usage: bool = False,
|
421
395
|
message_width: int = -1,
|
422
396
|
formatter: l.Formatter | None = None,
|
423
397
|
should_still_hold_messages: bool = False,
|
@@ -429,9 +403,9 @@ class logger_t(base_t):
|
|
429
403
|
self._should_activate_log_interceptions = False
|
430
404
|
|
431
405
|
self._should_hold_messages = should_still_hold_messages
|
406
|
+
|
432
407
|
handler = handler_t.New(
|
433
408
|
name=name,
|
434
|
-
should_store_memory_usage=should_store_memory_usage,
|
435
409
|
message_width=message_width,
|
436
410
|
level=level,
|
437
411
|
formatter=formatter,
|
@@ -439,31 +413,28 @@ class logger_t(base_t):
|
|
439
413
|
)
|
440
414
|
base_t.addHandler(self, handler)
|
441
415
|
|
442
|
-
extension = getattr(handler, "extension", None)
|
443
|
-
if extension is None:
|
444
|
-
name = handler.name
|
445
|
-
if (name is None) or (name.__len__() == 0):
|
446
|
-
name = ANONYMOUS
|
447
|
-
else:
|
448
|
-
name = getattr(extension, "name", ANONYMOUS)
|
449
|
-
if getattr(extension, STORE_MEMORY_ATTR, False):
|
450
|
-
self.any_handler_stores_memory = True
|
451
|
-
|
452
416
|
path = getattr(handler, "baseFilename", "")
|
453
417
|
if isinstance(path, path_t) or (path.__len__() > 0):
|
454
418
|
path = f"\nPath: {path}"
|
455
|
-
|
456
419
|
self.info(
|
457
|
-
f'New handler "{name}" of type "{type(handler).__name__}" and '
|
420
|
+
f'New handler "{handler.name}" of type "{type(handler).__name__}" and '
|
458
421
|
f"level {handler.level}={l.getLevelName(handler.level)}{path}"
|
459
422
|
)
|
460
423
|
|
461
424
|
def __call__(self, *args, **kwargs) -> None:
|
462
425
|
"""
|
463
|
-
For a print-like calling.
|
426
|
+
For a print-like calling for print-based debugging.
|
464
427
|
"""
|
465
428
|
separator = kwargs.get("separator", " ")
|
466
|
-
|
429
|
+
|
430
|
+
frame = e.stack(context=0)[1][0] # 1=caller.
|
431
|
+
details = e.getframeinfo(frame, context=0)
|
432
|
+
path = path_t(details.filename)
|
433
|
+
if path.is_relative_to(USER_FOLDER):
|
434
|
+
path = path.relative_to(USER_FOLDER)
|
435
|
+
where = f"{str(path.with_suffix(''))}.{details.function}.{details.lineno}"
|
436
|
+
|
437
|
+
self.info(separator.join(map(str, args)) + f"\n{WHERE_SEPARATOR} " + where)
|
467
438
|
|
468
439
|
def Log(
|
469
440
|
self,
|
@@ -510,7 +481,7 @@ class logger_t(base_t):
|
|
510
481
|
# - Why adding exception name here and not when removing caller?
|
511
482
|
formatted = "".join(lines)
|
512
483
|
message = f"Exception of type {type(exception).__name__}\n----\n{formatted}"
|
513
|
-
self.log(level, message, extra={
|
484
|
+
self.log(level, message, extra={SHOW_WHERE_ATTR: False})
|
514
485
|
|
515
486
|
def LogAsIs(self, message: str, /, *, indented: bool = False) -> None:
|
516
487
|
""""""
|
@@ -518,7 +489,7 @@ class logger_t(base_t):
|
|
518
489
|
message = text.indent(message, LINE_INDENT)
|
519
490
|
|
520
491
|
for handler in self.handlers:
|
521
|
-
handler.
|
492
|
+
handler.EmitAsIs(message)
|
522
493
|
|
523
494
|
info_raw = LogAsIs # To follow the convention of the logging methods info, error...
|
524
495
|
|
@@ -527,7 +498,7 @@ class logger_t(base_t):
|
|
527
498
|
) -> None:
|
528
499
|
""""""
|
529
500
|
for handler in self.handlers:
|
530
|
-
handler.
|
501
|
+
handler.EmitRule(text=message, color=color)
|
531
502
|
|
532
503
|
def AddContextLevel(self, new_level: str, /) -> None:
|
533
504
|
""""""
|
@@ -624,7 +595,7 @@ class logger_t(base_t):
|
|
624
595
|
formatted = "\n".join(lines)
|
625
596
|
"""
|
626
597
|
|
627
|
-
hide_where = {
|
598
|
+
hide_where = {SHOW_WHERE_ATTR: False}
|
628
599
|
if unified:
|
629
600
|
level, _ = issues[0].split(ISSUE_LEVEL_SEPARATOR, maxsplit=1)
|
630
601
|
wo_level = []
|
@@ -730,18 +701,4 @@ The fact that you are presently reading this means that you have had
|
|
730
701
|
knowledge of the CeCILL license and that you accept its terms.
|
731
702
|
|
732
703
|
SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
|
733
|
-
|
734
|
-
This software is being developed by Eric Debreuve, a CNRS employee and
|
735
|
-
member of team Morpheme.
|
736
|
-
Team Morpheme is a joint team between Inria, CNRS, and UniCA.
|
737
|
-
It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
|
738
|
-
I3S, and Laboratory iBV.
|
739
|
-
|
740
|
-
CNRS: https://www.cnrs.fr/index.php/en
|
741
|
-
Inria: https://www.inria.fr/en/
|
742
|
-
UniCA: https://univ-cotedazur.eu/
|
743
|
-
Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
|
744
|
-
I3S: https://www.i3s.unice.fr/en/
|
745
|
-
iBV: http://ibv.unice.fr/
|
746
|
-
Team Morpheme: https://team.inria.fr/morpheme/
|
747
704
|
"""
|
logger_36/type/loggers.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
"""
|
2
|
-
Copyright CNRS/
|
2
|
+
Copyright CNRS (https://www.cnrs.fr/index.php/en)
|
3
3
|
Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
4
4
|
SEE COPYRIGHT NOTICE BELOW
|
5
5
|
"""
|
@@ -8,7 +8,6 @@ import dataclasses as d
|
|
8
8
|
import logging as l
|
9
9
|
import typing as h
|
10
10
|
|
11
|
-
from logger_36.constant.logger import LOGGER_NAME
|
12
11
|
from logger_36.type.logger import logger_t
|
13
12
|
|
14
13
|
|
@@ -21,7 +20,7 @@ class loggers_t(dict[h.Hashable, logger_t]):
|
|
21
20
|
uid: h.Hashable,
|
22
21
|
/,
|
23
22
|
*,
|
24
|
-
name: str =
|
23
|
+
name: str | None = None,
|
25
24
|
level: int = l.NOTSET,
|
26
25
|
should_record_messages: bool = False,
|
27
26
|
exit_on_error: bool = False,
|
@@ -86,18 +85,4 @@ The fact that you are presently reading this means that you have had
|
|
86
85
|
knowledge of the CeCILL license and that you accept its terms.
|
87
86
|
|
88
87
|
SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
|
89
|
-
|
90
|
-
This software is being developed by Eric Debreuve, a CNRS employee and
|
91
|
-
member of team Morpheme.
|
92
|
-
Team Morpheme is a joint team between Inria, CNRS, and UniCA.
|
93
|
-
It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
|
94
|
-
I3S, and Laboratory iBV.
|
95
|
-
|
96
|
-
CNRS: https://www.cnrs.fr/index.php/en
|
97
|
-
Inria: https://www.inria.fr/en/
|
98
|
-
UniCA: https://univ-cotedazur.eu/
|
99
|
-
Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
|
100
|
-
I3S: https://www.i3s.unice.fr/en/
|
101
|
-
iBV: http://ibv.unice.fr/
|
102
|
-
Team Morpheme: https://team.inria.fr/morpheme/
|
103
88
|
"""
|
logger_36/type/message.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
"""
|
2
|
-
Copyright CNRS/
|
2
|
+
Copyright CNRS (https://www.cnrs.fr/index.php/en)
|
3
3
|
Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
4
4
|
SEE COPYRIGHT NOTICE BELOW
|
5
5
|
"""
|
@@ -73,18 +73,4 @@ The fact that you are presently reading this means that you have had
|
|
73
73
|
knowledge of the CeCILL license and that you accept its terms.
|
74
74
|
|
75
75
|
SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
|
76
|
-
|
77
|
-
This software is being developed by Eric Debreuve, a CNRS employee and
|
78
|
-
member of team Morpheme.
|
79
|
-
Team Morpheme is a joint team between Inria, CNRS, and UniCA.
|
80
|
-
It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
|
81
|
-
I3S, and Laboratory iBV.
|
82
|
-
|
83
|
-
CNRS: https://www.cnrs.fr/index.php/en
|
84
|
-
Inria: https://www.inria.fr/en/
|
85
|
-
UniCA: https://univ-cotedazur.eu/
|
86
|
-
Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
|
87
|
-
I3S: https://www.i3s.unice.fr/en/
|
88
|
-
iBV: http://ibv.unice.fr/
|
89
|
-
Team Morpheme: https://team.inria.fr/morpheme/
|
90
76
|
"""
|