logger-36 2024.28__py3-none-any.whl → 2024.29__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 +0 -1
- logger_36/catalog/handler/console.py +6 -9
- logger_36/catalog/handler/console_rich.py +16 -39
- logger_36/catalog/handler/file.py +6 -9
- logger_36/catalog/handler/generic.py +8 -12
- logger_36/catalog/logger/chronos.py +1 -2
- logger_36/catalog/logger/gpu.py +0 -2
- logger_36/catalog/logger/memory.py +6 -9
- logger_36/catalog/logger/system.py +0 -2
- logger_36/config/logger.py +2 -2
- logger_36/config/message.py +5 -6
- logger_36/constant/logger.py +0 -4
- logger_36/constant/message.py +3 -1
- logger_36/constant/record.py +3 -4
- logger_36/content.py +1 -1
- logger_36/handler.py +8 -16
- logger_36/task/format/memory.py +2 -2
- logger_36/task/format/message.py +1 -25
- logger_36/task/measure/chronos.py +19 -9
- logger_36/type/handler.py +34 -73
- logger_36/type/issue.py +2 -2
- logger_36/type/logger.py +95 -55
- logger_36/version.py +1 -1
- {logger_36-2024.28.dist-info → logger_36-2024.29.dist-info}/METADATA +1 -1
- logger_36-2024.29.dist-info/RECORD +52 -0
- {logger_36-2024.28.dist-info → logger_36-2024.29.dist-info}/WHEEL +1 -1
- logger_36-2024.28.dist-info/RECORD +0 -52
- {logger_36-2024.28.dist-info → logger_36-2024.29.dist-info}/top_level.txt +0 -0
@@ -5,25 +5,35 @@ SEE COPYRIGHT NOTICE BELOW
|
|
5
5
|
"""
|
6
6
|
|
7
7
|
import time
|
8
|
-
from datetime import datetime as
|
8
|
+
from datetime import datetime as date_time_t
|
9
9
|
|
10
10
|
# This module is imported early. Therefore, the current date and time should be close
|
11
11
|
# enough to the real start time of the main script.
|
12
|
-
_START_DATE_AND_TIME =
|
12
|
+
_START_DATE_AND_TIME = date_time_t.now()
|
13
13
|
|
14
14
|
|
15
15
|
def TimeStamp(*, precision: str = "microseconds") -> str:
|
16
16
|
""""""
|
17
|
-
return
|
17
|
+
return (
|
18
|
+
date_time_t.now()
|
19
|
+
.isoformat(timespec=precision)
|
20
|
+
.replace(".", "-")
|
21
|
+
.replace(":", "-")
|
22
|
+
)
|
18
23
|
|
19
24
|
|
20
|
-
def ElapsedTime(
|
25
|
+
def ElapsedTime(
|
26
|
+
*, should_return_now: bool = False
|
27
|
+
) -> str | tuple[str, date_time_t.date]:
|
21
28
|
""""""
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
29
|
+
now = date_time_t.now()
|
30
|
+
elapsed_seconds = (now - _START_DATE_AND_TIME).total_seconds()
|
31
|
+
output = time.strftime("%H:%M:%S", time.gmtime(elapsed_seconds))
|
32
|
+
while output.startswith("00:"):
|
33
|
+
output = output.split(sep=":", maxsplit=1)[-1]
|
34
|
+
|
35
|
+
if should_return_now:
|
36
|
+
return output, now
|
27
37
|
return output
|
28
38
|
|
29
39
|
|
logger_36/type/handler.py
CHANGED
@@ -8,15 +8,17 @@ import dataclasses as d
|
|
8
8
|
import logging as lggg
|
9
9
|
import sys as sstm
|
10
10
|
import typing as h
|
11
|
-
from os import sep as FOLDER_SEPARATOR
|
12
|
-
from pathlib import Path as path_t
|
13
11
|
|
14
|
-
from logger_36.config.message import
|
12
|
+
from logger_36.config.message import (
|
13
|
+
LEVEL_CLOSING,
|
14
|
+
LEVEL_OPENING,
|
15
|
+
MESSAGE_MARKER,
|
16
|
+
WHERE_SEPARATOR,
|
17
|
+
)
|
15
18
|
from logger_36.constant.error import MEMORY_MEASURE_ERROR
|
16
19
|
from logger_36.constant.handler import HANDLER_CODES
|
17
20
|
from logger_36.constant.message import NEXT_LINE_PROLOGUE
|
18
|
-
from logger_36.
|
19
|
-
from logger_36.task.format.message import FormattedMessage, MessageFormat
|
21
|
+
from logger_36.task.format.message import MessageWithActualExpected
|
20
22
|
from logger_36.task.measure.chronos import TimeStamp
|
21
23
|
from logger_36.task.measure.memory import CanCheckUsage as CanCheckMemoryUsage
|
22
24
|
|
@@ -26,10 +28,9 @@ _MEMORY_MEASURE_ERROR = MEMORY_MEASURE_ERROR
|
|
26
28
|
@d.dataclass(slots=True, repr=False, eq=False)
|
27
29
|
class handler_extension_t:
|
28
30
|
name: str | None = None
|
29
|
-
|
30
|
-
show_memory_usage: bool = False
|
31
|
+
should_store_memory_usage: bool = False
|
31
32
|
message_width: int = -1
|
32
|
-
|
33
|
+
MessageFromRecord: h.Callable[..., str] = d.field(init=False)
|
33
34
|
|
34
35
|
handler: d.InitVar[lggg.Handler | None] = None
|
35
36
|
level: d.InitVar[int] = lggg.NOTSET
|
@@ -43,7 +44,7 @@ class handler_extension_t:
|
|
43
44
|
|
44
45
|
if self.name in HANDLER_CODES:
|
45
46
|
raise ValueError(
|
46
|
-
|
47
|
+
MessageWithActualExpected(
|
47
48
|
"Invalid handler name",
|
48
49
|
actual=self.name,
|
49
50
|
expected=f"a name not in {str(HANDLER_CODES)[1:-1]}",
|
@@ -53,8 +54,8 @@ class handler_extension_t:
|
|
53
54
|
if self.name is None:
|
54
55
|
self.name = TimeStamp()
|
55
56
|
|
56
|
-
if self.
|
57
|
-
self.
|
57
|
+
if self.should_store_memory_usage and not CanCheckMemoryUsage():
|
58
|
+
self.should_store_memory_usage = False
|
58
59
|
if _MEMORY_MEASURE_ERROR is not None:
|
59
60
|
print(_MEMORY_MEASURE_ERROR, file=sstm.stderr)
|
60
61
|
_MEMORY_MEASURE_ERROR = None
|
@@ -64,85 +65,45 @@ class handler_extension_t:
|
|
64
65
|
if 0 < self.message_width < 5:
|
65
66
|
self.message_width = 5
|
66
67
|
if formatter is None:
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
68
|
+
self.MessageFromRecord = self._MessageFromRecord
|
69
|
+
else:
|
70
|
+
handler.setFormatter(formatter)
|
71
|
+
self.MessageFromRecord = handler.formatter.format
|
71
72
|
|
72
|
-
def
|
73
|
+
def _MessageFromRecord(
|
73
74
|
self,
|
74
75
|
record: lggg.LogRecord,
|
75
76
|
/,
|
76
77
|
*,
|
77
78
|
PreProcessed: h.Callable[[str], str] | None = None,
|
78
|
-
|
79
|
-
) -> tuple[str, str | None]:
|
79
|
+
) -> str:
|
80
80
|
"""
|
81
81
|
See logger_36.catalog.handler.README.txt.
|
82
82
|
"""
|
83
|
-
record.level_first_letter = record.levelname[0]
|
84
|
-
|
85
83
|
message = record.msg
|
86
|
-
if not isinstance(message, str):
|
87
|
-
message = str(message)
|
88
|
-
original_message = message
|
89
84
|
|
90
85
|
if PreProcessed is not None:
|
91
86
|
message = PreProcessed(message)
|
92
|
-
if (
|
93
|
-
|
94
|
-
|
95
|
-
if has_newlines:
|
96
|
-
lines = message.splitlines()
|
97
|
-
if self.message_width > 0:
|
98
|
-
lines = _WrappedLines(lines, self.message_width)
|
99
|
-
else:
|
100
|
-
lines = _WrappedLines([message], self.message_width)
|
101
|
-
next_lines = NEXT_LINE_PROLOGUE.join(lines[1:])
|
102
|
-
next_lines = f"{NEXT_LINE_PROLOGUE}{next_lines}"
|
103
|
-
message = lines[0]
|
87
|
+
if (self.message_width <= 0) or (message.__len__() <= self.message_width):
|
88
|
+
if "\n" in message:
|
89
|
+
message = NEXT_LINE_PROLOGUE.join(message.splitlines())
|
104
90
|
else:
|
105
|
-
|
106
|
-
|
107
|
-
n_missing_s = self.message_width - message.__len__()
|
108
|
-
if n_missing_s > 3:
|
109
|
-
message += " " + (n_missing_s - 1) * "."
|
110
|
-
elif n_missing_s > 0:
|
111
|
-
message += n_missing_s * " "
|
112
|
-
|
113
|
-
record.msg = message
|
114
|
-
if self.show_where and not hasattr(record, SHOW_WHERE_ATTR):
|
115
|
-
hide_where = getattr(record, HIDE_WHERE_ATTR, False)
|
116
|
-
if hide_where:
|
117
|
-
record.where = ""
|
91
|
+
if "\n" in message:
|
92
|
+
lines = _WrappedLines(message.splitlines(), self.message_width)
|
118
93
|
else:
|
119
|
-
|
120
|
-
|
121
|
-
for path in sstm.path:
|
122
|
-
if module.is_relative_to(path):
|
123
|
-
module = module.relative_to(path)
|
124
|
-
path_was_found = True
|
125
|
-
break
|
126
|
-
if path_was_found:
|
127
|
-
module = str(module.parent / module.stem)
|
128
|
-
module = module.replace(FOLDER_SEPARATOR, ".")
|
129
|
-
else:
|
130
|
-
module = record.module
|
131
|
-
record.where = WHERE_FORMAT.format(
|
132
|
-
module=module, funcName=record.funcName, lineno=record.lineno
|
133
|
-
)
|
134
|
-
first_line = self.FormattedRecord(record).replace("\t", " ")
|
135
|
-
|
136
|
-
# Revert the record message to its original value for subsequent handlers.
|
137
|
-
record.msg = original_message
|
94
|
+
lines = _WrappedLines([message], self.message_width)
|
95
|
+
message = NEXT_LINE_PROLOGUE.join(lines)
|
138
96
|
|
139
|
-
if
|
140
|
-
|
141
|
-
return first_line, None
|
142
|
-
else:
|
143
|
-
return f"{first_line}{next_lines}", None
|
97
|
+
if (where := getattr(record, "where", None)) is None:
|
98
|
+
where = ""
|
144
99
|
else:
|
145
|
-
|
100
|
+
where = f"{NEXT_LINE_PROLOGUE}{WHERE_SEPARATOR} {where}"
|
101
|
+
|
102
|
+
return (
|
103
|
+
f"{record.when_or_elapsed}"
|
104
|
+
f"{LEVEL_OPENING}{record.level_first_letter}{LEVEL_CLOSING} "
|
105
|
+
f"{MESSAGE_MARKER} {message}{where}"
|
106
|
+
)
|
146
107
|
|
147
108
|
|
148
109
|
def _WrappedLines(lines: list[str], message_width: int, /) -> list[str]:
|
logger_36/type/issue.py
CHANGED
@@ -11,7 +11,7 @@ from logger_36.config.issue import ISSUE_BASE_CONTEXT
|
|
11
11
|
from logger_36.constant.generic import NOT_PASSED
|
12
12
|
from logger_36.constant.issue import ISSUE_LEVEL_SEPARATOR
|
13
13
|
from logger_36.constant.message import expected_op_h
|
14
|
-
from logger_36.task.format.message import
|
14
|
+
from logger_36.task.format.message import MessageWithActualExpected
|
15
15
|
|
16
16
|
issue_t = str
|
17
17
|
|
@@ -32,7 +32,7 @@ def NewIssue(
|
|
32
32
|
""""""
|
33
33
|
if context.__len__() == 0:
|
34
34
|
context = ISSUE_BASE_CONTEXT
|
35
|
-
message =
|
35
|
+
message = MessageWithActualExpected(
|
36
36
|
message,
|
37
37
|
actual=actual,
|
38
38
|
expected=expected,
|
logger_36/type/logger.py
CHANGED
@@ -10,35 +10,47 @@ import sys as sstm
|
|
10
10
|
import traceback as tcbk
|
11
11
|
import types as t
|
12
12
|
import typing as h
|
13
|
-
from datetime import
|
13
|
+
from datetime import date as date_t
|
14
|
+
from datetime import datetime as date_time_t
|
15
|
+
from os import sep as FOLDER_SEPARATOR
|
14
16
|
from pathlib import Path as path_t
|
15
17
|
from traceback import TracebackException as traceback_t
|
16
18
|
|
17
19
|
from logger_36.config.issue import ISSUE_CONTEXT_END, ISSUE_CONTEXT_SEPARATOR
|
18
|
-
from logger_36.config.message import
|
20
|
+
from logger_36.config.message import (
|
21
|
+
DATE_FORMAT,
|
22
|
+
ELAPSED_TIME_SEPARATOR,
|
23
|
+
LONG_ENOUGH,
|
24
|
+
TIME_FORMAT,
|
25
|
+
)
|
19
26
|
from logger_36.constant.generic import NOT_PASSED
|
20
27
|
from logger_36.constant.issue import ISSUE_LEVEL_SEPARATOR, ORDER, order_h
|
21
28
|
from logger_36.constant.logger import (
|
22
|
-
HIDE_WHERE_KWARG,
|
23
29
|
LOGGER_NAME,
|
24
30
|
WARNING_LOGGER_NAME,
|
25
31
|
WARNING_TYPE_COMPILED_PATTERN,
|
26
32
|
logger_handle_h,
|
27
33
|
)
|
28
34
|
from logger_36.constant.memory import UNKNOWN_MEMORY_USAGE
|
29
|
-
from logger_36.constant.message import expected_op_h
|
30
|
-
from logger_36.constant.record import
|
31
|
-
|
32
|
-
|
35
|
+
from logger_36.constant.message import TIME_LENGTH_m_1, expected_op_h
|
36
|
+
from logger_36.constant.record import (
|
37
|
+
HIDE_WHERE_ATTR,
|
38
|
+
SHOW_W_RULE_ATTR,
|
39
|
+
STORE_MEMORY_ATTR,
|
33
40
|
)
|
34
|
-
from logger_36.task.format.message import
|
41
|
+
from logger_36.task.format.message import MessageWithActualExpected
|
35
42
|
from logger_36.task.measure.chronos import ElapsedTime
|
36
43
|
from logger_36.task.measure.memory import CurrentUsage as CurrentMemoryUsage
|
37
44
|
from logger_36.type.issue import NewIssue, issue_t
|
38
45
|
|
46
|
+
logger_base_t = lggg.Logger
|
47
|
+
|
48
|
+
_DATE_TIME_ORIGIN = date_time_t.fromtimestamp(1970, None)
|
49
|
+
_DATE_ORIGIN = _DATE_TIME_ORIGIN.date()
|
50
|
+
|
39
51
|
|
40
52
|
@d.dataclass(slots=True, repr=False, eq=False)
|
41
|
-
class logger_t(
|
53
|
+
class logger_t(logger_base_t):
|
42
54
|
name_: d.InitVar[str] = LOGGER_NAME
|
43
55
|
level_: d.InitVar[int] = lggg.NOTSET
|
44
56
|
activate_wrn_interceptions: d.InitVar[bool] = True
|
@@ -50,8 +62,9 @@ class logger_t(lggg.Logger):
|
|
50
62
|
|
51
63
|
on_hold: list[lggg.LogRecord] = d.field(init=False, default_factory=list)
|
52
64
|
events: dict[int, int] = d.field(init=False, default_factory=dict)
|
53
|
-
|
54
|
-
|
65
|
+
last_message_now: date_time_t = d.field(init=False, default=_DATE_TIME_ORIGIN)
|
66
|
+
last_message_date: date_t = d.field(init=False, default=_DATE_ORIGIN)
|
67
|
+
any_handler_stores_memory: bool = d.field(init=False, default=False)
|
55
68
|
memory_usages: list[tuple[str, int]] = d.field(init=False, default_factory=list)
|
56
69
|
context_levels: list[str] = d.field(init=False, default_factory=list)
|
57
70
|
staged_issues: list[issue_t] = d.field(init=False, default_factory=list)
|
@@ -64,9 +77,9 @@ class logger_t(lggg.Logger):
|
|
64
77
|
self, name_: str, level_: int, activate_wrn_interceptions: bool
|
65
78
|
) -> None:
|
66
79
|
""""""
|
67
|
-
|
80
|
+
logger_base_t.__init__(self, name_)
|
68
81
|
self.setLevel(level_)
|
69
|
-
self.propagate = False # Part of
|
82
|
+
self.propagate = False # Part of logger_base_t.
|
70
83
|
|
71
84
|
for level in lggg.getLevelNamesMapping().values():
|
72
85
|
self.events[level] = 0
|
@@ -92,7 +105,7 @@ class logger_t(lggg.Logger):
|
|
92
105
|
logger.handle = t.MethodType(_HandleForWarnings(self), logger)
|
93
106
|
|
94
107
|
lggg.captureWarnings(True)
|
95
|
-
self.info("Warning Interception: ON"
|
108
|
+
self.info("Warning Interception: ON")
|
96
109
|
|
97
110
|
def _DeactivateWarningInterceptions(self) -> None:
|
98
111
|
""""""
|
@@ -102,7 +115,7 @@ class logger_t(lggg.Logger):
|
|
102
115
|
self.intercepted_wrn_handle = None
|
103
116
|
|
104
117
|
lggg.captureWarnings(False)
|
105
|
-
self.info("Warning Interception: OFF"
|
118
|
+
self.info("Warning Interception: OFF")
|
106
119
|
|
107
120
|
def ToggleWarningInterceptions(self, state: bool, /) -> None:
|
108
121
|
""""""
|
@@ -130,16 +143,13 @@ class logger_t(lggg.Logger):
|
|
130
143
|
intercepted = sorted(self.intercepted_log_handles.keys())
|
131
144
|
if intercepted.__len__() > 0:
|
132
145
|
as_str = ", ".join(intercepted)
|
133
|
-
self.info(
|
134
|
-
f"Now Intercepting LOGs from: {as_str}",
|
135
|
-
**HIDE_WHERE_KWARG,
|
136
|
-
)
|
146
|
+
self.info(f"Now Intercepting LOGs from: {as_str}")
|
137
147
|
elif self.intercepted_log_handles.__len__() > 0:
|
138
148
|
for name, handle in self.intercepted_log_handles.items():
|
139
149
|
logger = lggg.getLogger(name)
|
140
150
|
logger.handle = handle
|
141
151
|
self.intercepted_log_handles.clear()
|
142
|
-
self.info("Log Interception: OFF"
|
152
|
+
self.info("Log Interception: OFF")
|
143
153
|
|
144
154
|
@property
|
145
155
|
def max_memory_usage(self) -> int:
|
@@ -162,15 +172,15 @@ class logger_t(lggg.Logger):
|
|
162
172
|
def AddHandler(self, handler: lggg.Handler, should_hold_messages: bool, /) -> None:
|
163
173
|
""""""
|
164
174
|
self.should_hold_messages = should_hold_messages
|
165
|
-
|
175
|
+
logger_base_t.addHandler(self, handler)
|
166
176
|
|
167
177
|
extension = getattr(handler, "extension", None)
|
168
178
|
if extension is None:
|
169
|
-
|
179
|
+
should_store_memory_usage = False
|
170
180
|
else:
|
171
|
-
|
172
|
-
if
|
173
|
-
self.
|
181
|
+
should_store_memory_usage = getattr(extension, STORE_MEMORY_ATTR, False)
|
182
|
+
if should_store_memory_usage:
|
183
|
+
self.any_handler_stores_memory = True
|
174
184
|
|
175
185
|
extension = getattr(handler, "extension", handler.name)
|
176
186
|
if isinstance(extension, str):
|
@@ -180,51 +190,75 @@ class logger_t(lggg.Logger):
|
|
180
190
|
self.info(
|
181
191
|
f'New handler "{name}" with class "{type(handler).__name__}" and '
|
182
192
|
f"level {lggg.getLevelName(handler.level)}",
|
183
|
-
**HIDE_WHERE_KWARG,
|
184
193
|
)
|
185
194
|
|
186
195
|
def handle(self, record: lggg.LogRecord, /) -> None:
|
187
196
|
""""""
|
188
|
-
|
189
|
-
for hold in self.on_hold:
|
190
|
-
lggg.Logger.handle(self, hold)
|
191
|
-
self.on_hold.clear()
|
192
|
-
|
193
|
-
record.elapsed_time = ElapsedTime()
|
197
|
+
elapsed_time, now = ElapsedTime(should_return_now=True)
|
194
198
|
|
195
|
-
if self.
|
196
|
-
|
197
|
-
|
198
|
-
self.
|
199
|
-
(f"{record.module}.{record.funcName}.{record.lineno}", usage)
|
200
|
-
)
|
201
|
-
|
202
|
-
value, unit = FormattedMemoryUsage(usage, 1)
|
203
|
-
record.memory_usage = f"{value}{unit}"
|
199
|
+
if (self.on_hold.__len__() > 0) and not self.should_hold_messages:
|
200
|
+
for held in self.on_hold:
|
201
|
+
logger_base_t.handle(self, held)
|
202
|
+
self.on_hold.clear()
|
204
203
|
|
205
|
-
date
|
206
|
-
if date != self.last_message_date:
|
204
|
+
if (date := now.date()) != self.last_message_date:
|
207
205
|
self.last_message_date = date
|
208
206
|
# levelno: Added for management by logging.Logger.handle.
|
209
207
|
date_record = lggg.makeLogRecord(
|
210
208
|
{
|
211
209
|
"name": self.name,
|
212
210
|
"levelno": lggg.INFO,
|
213
|
-
"msg": f"DATE: {date}",
|
211
|
+
"msg": f"DATE: {date.strftime(DATE_FORMAT)}",
|
214
212
|
SHOW_W_RULE_ATTR: True,
|
215
213
|
}
|
216
214
|
)
|
217
215
|
if self.should_hold_messages:
|
218
216
|
self.on_hold.append(date_record)
|
219
217
|
else:
|
220
|
-
|
218
|
+
logger_base_t.handle(self, date_record)
|
219
|
+
|
220
|
+
# When.
|
221
|
+
if now - self.last_message_now > LONG_ENOUGH:
|
222
|
+
record.when_or_elapsed = now.strftime(TIME_FORMAT)
|
223
|
+
else:
|
224
|
+
record.when_or_elapsed = (
|
225
|
+
f"{ELAPSED_TIME_SEPARATOR}{elapsed_time:.<{TIME_LENGTH_m_1}}"
|
226
|
+
)
|
227
|
+
self.last_message_now = now
|
228
|
+
|
229
|
+
# Where.
|
230
|
+
# Memory usage is also stored if there are no handlers yet, just in case.
|
231
|
+
should_store_where = self.any_handler_stores_memory or not self.hasHandlers()
|
232
|
+
should_show_where = (record.levelno != lggg.INFO) and not hasattr(
|
233
|
+
record, HIDE_WHERE_ATTR
|
234
|
+
)
|
235
|
+
if should_store_where or should_show_where:
|
236
|
+
module = path_t(record.pathname)
|
237
|
+
for path in sstm.path:
|
238
|
+
if module.is_relative_to(path):
|
239
|
+
module = module.relative_to(path).with_suffix("")
|
240
|
+
module = str(module).replace(FOLDER_SEPARATOR, ".")
|
241
|
+
break
|
242
|
+
else:
|
243
|
+
module = record.module
|
244
|
+
where = f"{module}:{record.funcName}:{record.lineno}"
|
245
|
+
if should_show_where:
|
246
|
+
record.where = where
|
247
|
+
else:
|
248
|
+
where = None
|
249
|
+
|
250
|
+
# How.
|
251
|
+
record.level_first_letter = record.levelname[0]
|
252
|
+
|
253
|
+
# What.
|
254
|
+
if not isinstance(record.msg, str):
|
255
|
+
record.msg = str(record.msg)
|
221
256
|
|
222
257
|
if self.should_hold_messages:
|
223
258
|
self.on_hold.append(record)
|
224
259
|
else:
|
225
|
-
|
260
|
+
logger_base_t.handle(self, record)
|
226
261
|
|
227
|
-
self.events[record.levelno] += 1
|
228
262
|
if (self.exit_on_critical and (record.levelno is lggg.CRITICAL)) or (
|
229
263
|
self.exit_on_error and (record.levelno is lggg.ERROR)
|
230
264
|
):
|
@@ -232,6 +266,11 @@ class logger_t(lggg.Logger):
|
|
232
266
|
# __post_init__ set self.exit_on_critical if self.exit_on_error.
|
233
267
|
sstm.exit(1)
|
234
268
|
|
269
|
+
self.events[record.levelno] += 1
|
270
|
+
|
271
|
+
if should_store_where:
|
272
|
+
self.memory_usages.append((where, CurrentMemoryUsage()))
|
273
|
+
|
235
274
|
def Log(
|
236
275
|
self,
|
237
276
|
message: str,
|
@@ -247,7 +286,7 @@ class logger_t(lggg.Logger):
|
|
247
286
|
""""""
|
248
287
|
if isinstance(level, str):
|
249
288
|
level = lggg.getLevelNamesMapping()[level.upper()]
|
250
|
-
message =
|
289
|
+
message = MessageWithActualExpected(
|
251
290
|
message,
|
252
291
|
actual=actual,
|
253
292
|
expected=expected,
|
@@ -357,7 +396,7 @@ class logger_t(lggg.Logger):
|
|
357
396
|
|
358
397
|
if order not in ORDER:
|
359
398
|
raise ValueError(
|
360
|
-
|
399
|
+
MessageWithActualExpected(
|
361
400
|
"Invalid commit order",
|
362
401
|
actual=order,
|
363
402
|
expected=f"One of {str(ORDER)[1:-1]}",
|
@@ -379,17 +418,18 @@ class logger_t(lggg.Logger):
|
|
379
418
|
formatted = "\n".join(lines)
|
380
419
|
"""
|
381
420
|
|
421
|
+
hide_where = {HIDE_WHERE_ATTR: None}
|
382
422
|
if unified:
|
383
423
|
level, _ = issues[0].split(ISSUE_LEVEL_SEPARATOR, maxsplit=1)
|
384
424
|
wo_level = []
|
385
425
|
for issue in issues:
|
386
426
|
_, issue = issue.split(ISSUE_LEVEL_SEPARATOR, maxsplit=1)
|
387
427
|
wo_level.append(issue)
|
388
|
-
self.log(int(level), "\n".join(wo_level), stacklevel=2)
|
428
|
+
self.log(int(level), "\n".join(wo_level), stacklevel=2, extra=hide_where)
|
389
429
|
else:
|
390
430
|
for issue in issues:
|
391
431
|
level, issue = issue.split(ISSUE_LEVEL_SEPARATOR, maxsplit=1)
|
392
|
-
self.log(int(level), issue, stacklevel=2)
|
432
|
+
self.log(int(level), issue, stacklevel=2, extra=hide_where)
|
393
433
|
self.staged_issues.clear()
|
394
434
|
|
395
435
|
def __enter__(self) -> None:
|
@@ -408,10 +448,10 @@ class logger_t(lggg.Logger):
|
|
408
448
|
return False
|
409
449
|
|
410
450
|
|
411
|
-
def _HandleForWarnings(interceptor:
|
451
|
+
def _HandleForWarnings(interceptor: logger_base_t, /) -> logger_handle_h:
|
412
452
|
""""""
|
413
453
|
|
414
|
-
def handle_p(_:
|
454
|
+
def handle_p(_: logger_base_t, record: lggg.LogRecord, /) -> None:
|
415
455
|
pieces = WARNING_TYPE_COMPILED_PATTERN.match(record.msg)
|
416
456
|
if pieces is None:
|
417
457
|
# The warning message does not follow the default format.
|
@@ -437,11 +477,11 @@ def _HandleForWarnings(interceptor: lggg.Logger, /) -> logger_handle_h:
|
|
437
477
|
|
438
478
|
|
439
479
|
def _HandleForInterceptions(
|
440
|
-
intercepted:
|
480
|
+
intercepted: logger_base_t, interceptor: logger_base_t, /
|
441
481
|
) -> logger_handle_h:
|
442
482
|
""""""
|
443
483
|
|
444
|
-
def handle_p(_:
|
484
|
+
def handle_p(_: logger_base_t, record: lggg.LogRecord, /) -> None:
|
445
485
|
duplicate = lggg.makeLogRecord(record.__dict__)
|
446
486
|
duplicate.msg = f"{record.msg} :{intercepted.name}:"
|
447
487
|
interceptor.handle(duplicate)
|
logger_36/version.py
CHANGED
@@ -0,0 +1,52 @@
|
|
1
|
+
logger_36/__init__.py,sha256=NtDTs3eMKaXTJeujmgj1um3cBVLti0tYuOsdtVk9o9Q,2269
|
2
|
+
logger_36/content.py,sha256=ni9gdYYNZoDa91KNianWBluOBe9KxZMZtzalcBS6vhE,2357
|
3
|
+
logger_36/exception.py,sha256=UsFcsAvd1L4aLj6h7T-DilDm6yO501HDYnGekibiMAU,3260
|
4
|
+
logger_36/gpu.py,sha256=YYFk6aYQrBDJfxQaDm-ar16T6SlOSL6jJWTOgvpF4EU,2244
|
5
|
+
logger_36/handler.py,sha256=vg8LOD0YzGQxyoKB7qr7c4rueRwp-sDF1svDHwffumg,6565
|
6
|
+
logger_36/memory.py,sha256=FTc3qCeMqnCNvHJ4Yds73noPENQx_U1MYB-R4LLUjVQ,2682
|
7
|
+
logger_36/storage.py,sha256=TNfIXEfHcjixv75wocUyqwX62iDYsor4srRqC3FNzbc,2231
|
8
|
+
logger_36/system.py,sha256=xzm6cMeTaCX9VX9ZRXUXgfqoT9oUtv3W2o_H2W0P-4Q,2243
|
9
|
+
logger_36/time.py,sha256=_CtpQeUZdsUNGNfwzhoWUiUvawRgmonqwZPHouzWf5M,2308
|
10
|
+
logger_36/version.py,sha256=FPamC8R6aakwwSJ4-41eIPnI5eDVF1QjdoZc8H7gmdA,2206
|
11
|
+
logger_36/api/logger.py,sha256=Wg2nzQeuRVZ4v-oy3Q2KdYsHSzF9v7a0Fk6BzLnbkYw,2225
|
12
|
+
logger_36/api/storage.py,sha256=evKVqIsslA5X82LaZ2HQDxp7ltyNOn8Tr-3-Pic3eUo,2231
|
13
|
+
logger_36/catalog/config/console_rich.py,sha256=iyPFozVpw18qkRTBovhb2X2WM93MW5QqgwGQDSzUijI,2866
|
14
|
+
logger_36/catalog/handler/console.py,sha256=KL8oGdtQUUE8I5Pc_5wmD1MdDSw8E7dpybkzmFWKRUY,4247
|
15
|
+
logger_36/catalog/handler/console_rich.py,sha256=of4C26UZcA10-dBrdRGWVk4u9NycX_9VIgINGevEB14,8330
|
16
|
+
logger_36/catalog/handler/file.py,sha256=JgtfBQfgQldxqogzAVYOquX3pLE-qOqnbhZbu9H3tXo,4699
|
17
|
+
logger_36/catalog/handler/generic.py,sha256=U1X2B7ptLWtdtiDh_Lri55JmygTPnY9wXwmFsPZcZuE,9002
|
18
|
+
logger_36/catalog/logger/chronos.py,sha256=7_Y_HxRHwwHyjOb2v4Y3CxMGCaJBWm7q8wlw05jZGvs,2447
|
19
|
+
logger_36/catalog/logger/gpu.py,sha256=QPESzp3V-Qhx2A99A5N3IsM9tA6ikqSPos0MKJyu-ls,3407
|
20
|
+
logger_36/catalog/logger/memory.py,sha256=Wv6thZ4ydM_x3mZkpz6XnOm7jaWjXWb3mEQuk4EKXb0,4693
|
21
|
+
logger_36/catalog/logger/system.py,sha256=WRDlh0tr8NYp6AeVjLkmzuBMwtJxSokl4_mMJRH9OBU,3076
|
22
|
+
logger_36/config/issue.py,sha256=G-i5p6lhZCLAOa-VTMyL9ZonvGCvhdoQ5KZdSWgP-FU,2267
|
23
|
+
logger_36/config/logger.py,sha256=9vQ8m1sJsK8tjnh5SZEKzofqeVJbsULTm-ev2rk0x7M,3760
|
24
|
+
logger_36/config/memory.py,sha256=yCX5phsB_KJMr5xHpVUeOHFhAA7p_8yahP3X28VndOY,2217
|
25
|
+
logger_36/config/message.py,sha256=yfbMO_Jk1IbWvT6Lp6hVpID2Tr99cuiJ-ZaMBesIFXw,2527
|
26
|
+
logger_36/config/system.py,sha256=HD8ZuwsXhEAExeZrww8YoDkQGMs4T5RDqQMb1W4qVgc,2477
|
27
|
+
logger_36/constant/error.py,sha256=1gdnCwUu3d3ThL4AKxzjn7ijSTBWlr2g-8cAKbubl4A,2825
|
28
|
+
logger_36/constant/generic.py,sha256=t6aRb66_NHwMhR1p7BZ4QXTU2jpLz-H5YAL4PuMtKx8,2244
|
29
|
+
logger_36/constant/handler.py,sha256=HM8qCSEMGNMCzddjUUNBPGL-3d0qU-EmG5eW4ZQHW6A,2311
|
30
|
+
logger_36/constant/issue.py,sha256=01l8itRPWGS5F6gXtsXUJgGR-4lS1Eu3_YeKC-khKLw,2315
|
31
|
+
logger_36/constant/logger.py,sha256=QkaFk3I9JF83nkzrk8c1Jl0j_eSTEzGyeJbNgQdoSlE,2670
|
32
|
+
logger_36/constant/memory.py,sha256=ZL1MwbdtNsrCrOwzEyfTsfOoOsRBTJtbbf3otHGnxXo,2343
|
33
|
+
logger_36/constant/message.py,sha256=Ys_CAyhENlT8Z3rr-AxO4hjdl1jLsKzVSPQ8wqLOCPQ,2838
|
34
|
+
logger_36/constant/record.py,sha256=9Q28lVH_s0og4v74delgwIPAJ9G28I5rBM-brXcoY80,2308
|
35
|
+
logger_36/constant/system.py,sha256=G2mzBTxRXoJMxb53TnmBaceMJC_q3WonoCG7y6nC_R8,2430
|
36
|
+
logger_36/instance/logger.py,sha256=ttKjl9MD7FUjqCWjv5w2hmmpDYxgaORcYf9NaaE9W_M,2246
|
37
|
+
logger_36/instance/loggers.py,sha256=RCWpC1NPAf6vXnFc9NqsSALv-x-FEzcH6k_OlxTxeQk,2251
|
38
|
+
logger_36/task/inspection.py,sha256=f9VkVrwMJ_ixV9rFu3XUNpmCbEgoo1tssqd2nMeGYLI,5028
|
39
|
+
logger_36/task/storage.py,sha256=XaSeu-iBCa0N8HNpwCV7cLprj-lbOJocpTIKUgSOvsc,5668
|
40
|
+
logger_36/task/format/memory.py,sha256=WDwRwuZbYwNxXIe_xo-r0XJtFZ0gRnE6wgTaXx_fEbc,4259
|
41
|
+
logger_36/task/format/message.py,sha256=T2V2gUlUQqSojyRrz4I4uAHwNe6eBEsuAe6V-LTyx0k,3867
|
42
|
+
logger_36/task/format/rule.py,sha256=M4a8uW7FEvMI9f4s32A9-DoP0WVlLkyXamGnqbzZ65A,2797
|
43
|
+
logger_36/task/measure/chronos.py,sha256=OhQHPFKJvTEizpj7Uvysu8r9dTpzPgKz1SoTztlEcnI,3066
|
44
|
+
logger_36/task/measure/memory.py,sha256=eVw5WOYLyn8o4O4mMArdX2MzsVuhhNDovjYEkk-MIaU,2504
|
45
|
+
logger_36/type/handler.py,sha256=HJ547swaN1bdxnxoU4cIinWUkww3YAQ1vYgtugWk5X4,6474
|
46
|
+
logger_36/type/issue.py,sha256=p2upR8vAXPkrnSwPuM3R1hmTkRwJwL1e658L6WwSWfQ,3220
|
47
|
+
logger_36/type/logger.py,sha256=kYPiUOR_qs9DWBaHH4damx7xsh-OlFbYLHY1enyzn3w,18884
|
48
|
+
logger_36/type/loggers.py,sha256=znqxWBnfQxvkg3VUfbTUvt3S6Kq0DAzWWepxQDt9suI,2871
|
49
|
+
logger_36-2024.29.dist-info/METADATA,sha256=vV3RAljMWV9CptX6oIUtgz6sqQflABEhCCymI6-hBGw,6276
|
50
|
+
logger_36-2024.29.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
51
|
+
logger_36-2024.29.dist-info/top_level.txt,sha256=sM95BTMWmslEEgR_1pzwZsOeSp8C_QBiu8ImbFr0XLc,10
|
52
|
+
logger_36-2024.29.dist-info/RECORD,,
|