logger-36 2024.1__py3-none-any.whl → 2024.2__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.
Files changed (41) hide show
  1. logger_36/__init__.py +2 -7
  2. logger_36/catalog/config/console_rich.py +49 -0
  3. logger_36/catalog/handler/console.py +80 -0
  4. logger_36/{type/console.py → catalog/handler/console_rich.py} +77 -52
  5. logger_36/catalog/handler/file.py +90 -0
  6. logger_36/catalog/handler/generic.py +150 -0
  7. logger_36/catalog/logging/chronos.py +39 -0
  8. logger_36/catalog/{gpu.py → logging/gpu.py} +3 -1
  9. logger_36/catalog/logging/memory.py +105 -0
  10. logger_36/catalog/{system.py → logging/system.py} +5 -27
  11. logger_36/config/issue.py +32 -0
  12. logger_36/config/memory.py +33 -0
  13. logger_36/{config.py → config/message.py} +14 -14
  14. logger_36/config/system.py +49 -0
  15. logger_36/constant/generic.py +37 -0
  16. logger_36/constant/handler.py +35 -0
  17. logger_36/constant/issue.py +35 -0
  18. logger_36/{type/file.py → constant/logger.py} +13 -15
  19. logger_36/constant/memory.py +39 -0
  20. logger_36/{constant.py → constant/message.py} +11 -15
  21. logger_36/constant/record.py +35 -0
  22. logger_36/constant/system.py +39 -0
  23. logger_36/instance.py +5 -5
  24. logger_36/main.py +130 -32
  25. logger_36/{catalog → task/format}/memory.py +34 -33
  26. logger_36/task/format/message.py +112 -0
  27. logger_36/task/format/rule.py +47 -0
  28. logger_36/task/inspection.py +18 -18
  29. logger_36/{measure → task/measure}/chronos.py +4 -2
  30. logger_36/task/storage.py +64 -3
  31. logger_36/type/extension.py +73 -61
  32. logger_36/type/issue.py +57 -0
  33. logger_36/type/logger.py +349 -0
  34. logger_36/version.py +1 -1
  35. {logger_36-2024.1.dist-info → logger_36-2024.2.dist-info}/METADATA +1 -2
  36. logger_36-2024.2.dist-info/RECORD +39 -0
  37. {logger_36-2024.1.dist-info → logger_36-2024.2.dist-info}/WHEEL +1 -1
  38. logger_36/type/generic.py +0 -115
  39. logger_36-2024.1.dist-info/RECORD +0 -21
  40. /logger_36/{measure → task/measure}/memory.py +0 -0
  41. {logger_36-2024.1.dist-info → logger_36-2024.2.dist-info}/top_level.txt +0 -0
@@ -29,94 +29,106 @@
29
29
  # The fact that you are presently reading this means that you have had
30
30
  # knowledge of the CeCILL license and that you accept its terms.
31
31
 
32
+ import dataclasses as dtcl
32
33
  import logging as lggg
33
34
  import sys as sstm
34
- from typing import Callable
35
+ import typing as h
35
36
 
36
- from logger_36.catalog.memory import WithAutoUnit as MemoryWithAutoUnit
37
- from logger_36.config import DATE_TIME_FORMAT, MESSAGE_FORMAT
38
- from logger_36.constant import LOG_LEVEL_LENGTH, NEXT_LINE_PROLOGUE
39
- from logger_36.measure.chronos import ElapsedTime
40
- from logger_36.measure.memory import CurrentUsage as CurrentMemoryUsage
37
+ from logger_36.config.message import TIME_FORMAT, WHERE_FORMAT
38
+ from logger_36.constant.handler import HANDLER_CODES
39
+ from logger_36.constant.memory import MEMORY_MEASURE_ERROR
40
+ from logger_36.constant.message import NEXT_LINE_PROLOGUE
41
+ from logger_36.constant.record import HIDE_WHERE_ATTR, SHOW_WHERE_ATTR
42
+ from logger_36.task.format.message import FormattedMessage, MessageFormat
43
+ from logger_36.task.measure.chronos import TimeStamp
44
+ from logger_36.task.measure.memory import CanCheckMemory
41
45
 
42
46
 
47
+ @dtcl.dataclass(slots=True, repr=False, eq=False)
43
48
  class handler_extension_t:
44
- __slots__ = ("formatter", "show_memory_usage", "max_memory_usage", "exit_on_error")
45
- formatter: lggg.Formatter
46
- show_memory_usage: bool
47
- max_memory_usage: int
48
- exit_on_error: bool
49
+ name: str | None = None
50
+ show_where: bool = True
51
+ show_memory_usage: bool = False
52
+ FormattedRecord: h.Callable[[lggg.LogRecord], str] = dtcl.field(init=False)
49
53
 
50
- def __init__(self) -> None:
54
+ handler: dtcl.InitVar[lggg.Handler | None] = None
55
+ level: dtcl.InitVar[int] = lggg.NOTSET
56
+ formatter: dtcl.InitVar[lggg.Formatter | None] = None
57
+
58
+ def __post_init__(
59
+ self, handler: lggg.Handler | None, level: int, formatter: lggg.Formatter | None
60
+ ) -> None:
51
61
  """"""
52
- self.formatter = lggg.Formatter(fmt=MESSAGE_FORMAT, datefmt=DATE_TIME_FORMAT)
53
- self.show_memory_usage = False
54
- self.max_memory_usage = -1
55
- self.exit_on_error = False
62
+ if self.name in HANDLER_CODES:
63
+ raise ValueError(
64
+ FormattedMessage(
65
+ "Invalid handler name",
66
+ actual=self.name,
67
+ expected=f"a name not in {str(HANDLER_CODES)[1:-1]}",
68
+ )
69
+ )
70
+
71
+ if self.name is None:
72
+ self.name = TimeStamp()
73
+
74
+ if self.show_memory_usage and not CanCheckMemory():
75
+ self.show_memory_usage = False
76
+ print(MEMORY_MEASURE_ERROR, file=sstm.stderr)
77
+
78
+ handler.setLevel(level)
56
79
 
57
- def MessageLines(
80
+ if formatter is None:
81
+ message_format = MessageFormat(self.show_where, self.show_memory_usage)
82
+ formatter = lggg.Formatter(fmt=message_format, datefmt=TIME_FORMAT)
83
+ handler.setFormatter(formatter)
84
+ self.FormattedRecord = handler.formatter.format
85
+
86
+ def FormattedLines(
58
87
  self,
59
88
  record: lggg.LogRecord,
60
89
  /,
61
90
  *,
62
- PreProcessed: Callable[[str], str] | None = None,
63
- should_fully_format: bool = False,
91
+ PreProcessed: h.Callable[[str], str] | None = None,
92
+ should_join_lines: bool = False,
64
93
  ) -> tuple[str, str | None]:
65
94
  """
66
- Note: "message" is not yet an attribute of record (it will be set by format());
67
- Use "msg" instead.
95
+ See logger_36.catalog.handler.README.txt.
68
96
  """
69
- if not isinstance(record.msg, str):
70
- record.msg = str(record.msg)
97
+ record.level_first_letter = record.levelname[0]
98
+
99
+ message = record.msg
100
+ if not isinstance(message, str):
101
+ message = str(message)
102
+ original_message = message
103
+
71
104
  if PreProcessed is not None:
72
- record.msg = PreProcessed(record.msg)
73
- if "\n" in record.msg:
74
- original_message = record.msg
75
- lines = original_message.splitlines()
76
- record.msg = lines[0]
105
+ message = PreProcessed(message)
106
+ if "\n" in message:
107
+ lines = message.splitlines()
77
108
  next_lines = NEXT_LINE_PROLOGUE.join(lines[1:])
78
109
  next_lines = f"{NEXT_LINE_PROLOGUE}{next_lines}"
110
+ message = lines[0]
79
111
  else:
80
- original_message = next_lines = None
81
-
82
- # The record is shared between handlers, so do not re-assign if already there.
83
- if not hasattr(record, "elapsed_time"):
84
- record.elapsed_time = ElapsedTime()
85
- # Re-assign for each handler in case they have different show properties.
86
- if self.show_memory_usage:
87
- record.memory_usage = self.FormattedMemoryUsage()
88
- else:
89
- record.memory_usage = ""
112
+ next_lines = None
90
113
 
91
- padding = (LOG_LEVEL_LENGTH - record.levelname.__len__() - 1) * " "
92
- first_line = self.formatter.format(record).replace("\t", padding)
114
+ record.msg = message
115
+ if self.show_where and not hasattr(record, SHOW_WHERE_ATTR):
116
+ hide_where = getattr(record, HIDE_WHERE_ATTR, False)
117
+ if hide_where:
118
+ record.where = ""
119
+ else:
120
+ record.where = WHERE_FORMAT.format(
121
+ module=record.module, funcName=record.funcName, lineno=record.lineno
122
+ )
123
+ first_line = self.FormattedRecord(record).replace("\t", " ")
93
124
 
94
125
  # Revert the record message to its original value for subsequent handlers.
95
- if original_message is not None:
96
- record.msg = original_message
126
+ record.msg = original_message
97
127
 
98
- if should_fully_format:
128
+ if should_join_lines:
99
129
  if next_lines is None:
100
130
  return first_line, None
101
131
  else:
102
132
  return f"{first_line}{next_lines}", None
103
133
  else:
104
134
  return first_line, next_lines
105
-
106
- def FormattedMemoryUsage(self) -> str:
107
- """"""
108
- if self.show_memory_usage:
109
- usage = CurrentMemoryUsage()
110
- if usage > self.max_memory_usage:
111
- self.max_memory_usage = usage
112
-
113
- usage, unit = MemoryWithAutoUnit(usage, 1)
114
-
115
- return f" :{usage}{unit}"
116
- else:
117
- return ""
118
-
119
- def ExitOrNotIfError(self, record: lggg.LogRecord, /) -> None:
120
- """"""
121
- if self.exit_on_error and (record.levelno in (lggg.ERROR, lggg.CRITICAL)):
122
- sstm.exit(1)
@@ -0,0 +1,57 @@
1
+ # Copyright CNRS/Inria/UCA
2
+ # Contributor(s): Eric Debreuve (since 2023)
3
+ #
4
+ # eric.debreuve@cnrs.fr
5
+ #
6
+ # This software is governed by the CeCILL license under French law and
7
+ # abiding by the rules of distribution of free software. You can use,
8
+ # modify and/ or redistribute the software under the terms of the CeCILL
9
+ # license as circulated by CEA, CNRS and INRIA at the following URL
10
+ # "http://www.cecill.info".
11
+ #
12
+ # As a counterpart to the access to the source code and rights to copy,
13
+ # modify and redistribute granted by the license, users are provided only
14
+ # with a limited warranty and the software's author, the holder of the
15
+ # economic rights, and the successive licensors have only limited
16
+ # liability.
17
+ #
18
+ # In this respect, the user's attention is drawn to the risks associated
19
+ # with loading, using, modifying and/or developing or reproducing the
20
+ # software by the user in light of its specific status of free software,
21
+ # that may mean that it is complicated to manipulate, and that also
22
+ # therefore means that it is reserved for developers and experienced
23
+ # professionals having in-depth computer knowledge. Users are therefore
24
+ # encouraged to load and test the software's suitability as regards their
25
+ # requirements in conditions enabling the security of their systems and/or
26
+ # data to be ensured and, more generally, to use and operate it in the
27
+ # same conditions as regards security.
28
+ #
29
+ # The fact that you are presently reading this means that you have had
30
+ # knowledge of the CeCILL license and that you accept its terms.
31
+
32
+ import typing as h
33
+
34
+ from logger_36.config.issue import BASE_CONTEXT
35
+ from logger_36.constant.generic import NOT_PASSED
36
+ from logger_36.task.format.message import FormattedMessage
37
+
38
+ issue_t = str
39
+
40
+
41
+ def NewIssue(
42
+ context: str,
43
+ separator: str,
44
+ message: str,
45
+ /,
46
+ *,
47
+ actual: h.Any = NOT_PASSED,
48
+ expected: h.Any | None = None,
49
+ ) -> issue_t:
50
+ """"""
51
+ if context.__len__() == 0:
52
+ context = BASE_CONTEXT
53
+ message = FormattedMessage(
54
+ message, actual=actual, expected=expected, with_final_dot=False
55
+ )
56
+
57
+ return f"{context}{separator}{message}"
@@ -0,0 +1,349 @@
1
+ # Copyright CNRS/Inria/UCA
2
+ # Contributor(s): Eric Debreuve (since 2023)
3
+ #
4
+ # eric.debreuve@cnrs.fr
5
+ #
6
+ # This software is governed by the CeCILL license under French law and
7
+ # abiding by the rules of distribution of free software. You can use,
8
+ # modify and/ or redistribute the software under the terms of the CeCILL
9
+ # license as circulated by CEA, CNRS and INRIA at the following URL
10
+ # "http://www.cecill.info".
11
+ #
12
+ # As a counterpart to the access to the source code and rights to copy,
13
+ # modify and redistribute granted by the license, users are provided only
14
+ # with a limited warranty and the software's author, the holder of the
15
+ # economic rights, and the successive licensors have only limited
16
+ # liability.
17
+ #
18
+ # In this respect, the user's attention is drawn to the risks associated
19
+ # with loading, using, modifying and/or developing or reproducing the
20
+ # software by the user in light of its specific status of free software,
21
+ # that may mean that it is complicated to manipulate, and that also
22
+ # therefore means that it is reserved for developers and experienced
23
+ # professionals having in-depth computer knowledge. Users are therefore
24
+ # encouraged to load and test the software's suitability as regards their
25
+ # requirements in conditions enabling the security of their systems and/or
26
+ # data to be ensured and, more generally, to use and operate it in the
27
+ # same conditions as regards security.
28
+ #
29
+ # The fact that you are presently reading this means that you have had
30
+ # knowledge of the CeCILL license and that you accept its terms.
31
+
32
+ from __future__ import annotations
33
+
34
+ import dataclasses as dtcl
35
+ import logging as lggg
36
+ import sys as sstm
37
+ import types as t
38
+ import typing as h
39
+ from datetime import datetime as dttm
40
+ from pathlib import Path as path_t
41
+ from traceback import TracebackException as traceback_t
42
+
43
+ from logger_36.config.message import DATE_FORMAT, INTERCEPTED_LOG_SEPARATOR
44
+ from logger_36.constant.generic import NOT_PASSED
45
+ from logger_36.constant.issue import ORDER, order_h
46
+ from logger_36.constant.logger import (
47
+ HIDE_WHERE_KWARG,
48
+ LOGGER_NAME,
49
+ WARNING_LOGGER_NAME,
50
+ WARNING_TYPE_COMPILED_PATTERN,
51
+ logger_handle_h,
52
+ )
53
+ from logger_36.constant.record import SHOW_MEMORY_ATTR, SHOW_W_RULE_ATTR
54
+ from logger_36.task.format.memory import (
55
+ FormattedUsageWithAutoUnit as FormattedMemoryUsage,
56
+ )
57
+ from logger_36.task.format.message import FormattedMessage
58
+ from logger_36.task.measure.chronos import ElapsedTime
59
+ from logger_36.task.measure.memory import CurrentUsage as CurrentMemoryUsage
60
+ from logger_36.type.issue import NewIssue, issue_t
61
+
62
+
63
+ @dtcl.dataclass(slots=True, repr=False, eq=False)
64
+ class logger_t(lggg.Logger):
65
+ ISSUE_CONTEXT_SEPARATOR: h.ClassVar[str] = ">"
66
+ ISSUE_CONTEXT_END: h.ClassVar[str] = ":: "
67
+
68
+ # Must not be False until at least one handler has been added.
69
+ should_hold_messages: bool = True
70
+
71
+ name: dtcl.InitVar[str] = LOGGER_NAME
72
+ level: dtcl.InitVar[int] = lggg.NOTSET
73
+ activate_wrn_interceptions: dtcl.InitVar[bool] = True
74
+ exit_on_error: bool = False
75
+
76
+ on_hold: list[lggg.LogRecord] = dtcl.field(init=False, default_factory=list)
77
+ last_message_date: str = dtcl.field(init=False, default="")
78
+ any_handler_shows_memory: bool = dtcl.field(init=False, default=False)
79
+ memory_usages: list[tuple[str, int]] = dtcl.field(init=False, default_factory=list)
80
+ context_levels: list[str] = dtcl.field(init=False, default_factory=list)
81
+ staged_issues: list[issue_t] = dtcl.field(init=False, default_factory=list)
82
+ intercepted_wrn_handle: logger_handle_h | None = dtcl.field(
83
+ init=False, default=None
84
+ )
85
+ intercepted_log_handles: dict[str, logger_handle_h] = dtcl.field(
86
+ init=False, default_factory=dict
87
+ )
88
+
89
+ def __post_init__(
90
+ self, name: str, level: int, activate_wrn_interceptions: bool
91
+ ) -> None:
92
+ """"""
93
+ lggg.Logger.__init__(self, name)
94
+ self.setLevel(level)
95
+ self.propagate = False
96
+
97
+ if activate_wrn_interceptions:
98
+ self._ActivateWarningInterceptions()
99
+
100
+ def _ActivateWarningInterceptions(self) -> None:
101
+ """
102
+ The log message will not appear if called from __post_init__ since there are no
103
+ handlers yet.
104
+ """
105
+ if self.intercepted_wrn_handle is None:
106
+ logger = lggg.getLogger(WARNING_LOGGER_NAME)
107
+
108
+ self.intercepted_wrn_handle = logger.handle
109
+ logger.handle = t.MethodType(_HandleForWarnings(self), logger)
110
+
111
+ lggg.captureWarnings(True)
112
+ self.info("Warning Interception: ON", **HIDE_WHERE_KWARG)
113
+
114
+ def _DeactivateWarningInterceptions(self) -> None:
115
+ """"""
116
+ if self.intercepted_wrn_handle is not None:
117
+ logger = lggg.getLogger(WARNING_LOGGER_NAME)
118
+
119
+ logger.handle = self.intercepted_wrn_handle
120
+ self.intercepted_wrn_handle = None
121
+
122
+ lggg.captureWarnings(False)
123
+ self.info("Warning Interception: OFF", **HIDE_WHERE_KWARG)
124
+
125
+ def ToggleWarningInterceptions(self, state: bool, /) -> None:
126
+ """"""
127
+ if state:
128
+ self._ActivateWarningInterceptions()
129
+ else:
130
+ self._DeactivateWarningInterceptions()
131
+
132
+ def ToggleLogInterceptions(self, state: bool, /) -> None:
133
+ """"""
134
+ if state:
135
+ self.ToggleLogInterceptions(False)
136
+
137
+ all_loggers = [lggg.getLogger()] + [
138
+ lggg.getLogger(_nme)
139
+ for _nme in self.manager.loggerDict
140
+ if _nme not in (self.name, WARNING_LOGGER_NAME)
141
+ ]
142
+ for logger in all_loggers:
143
+ self.intercepted_log_handles[logger.name] = logger.handle
144
+ logger.handle = t.MethodType(
145
+ _HandleForInterceptions(logger, self), logger
146
+ )
147
+
148
+ intercepted = sorted(self.intercepted_log_handles.keys())
149
+ if intercepted.__len__() > 0:
150
+ self.info(
151
+ f"Now Intercepting LOGs from: {str(intercepted)[1:-1]}",
152
+ **HIDE_WHERE_KWARG,
153
+ )
154
+ elif self.intercepted_log_handles.__len__() > 0:
155
+ for name, handle in self.intercepted_log_handles.items():
156
+ logger = lggg.getLogger(name)
157
+ logger.handle = handle
158
+ self.intercepted_log_handles.clear()
159
+ self.info("Log Interception: OFF", **HIDE_WHERE_KWARG)
160
+
161
+ @property
162
+ def max_memory_usage(self) -> int:
163
+ """"""
164
+ return max(tuple(zip(*self.memory_usages))[1])
165
+
166
+ @property
167
+ def max_memory_usage_full(self) -> tuple[str, int]:
168
+ """"""
169
+ where_s, usages = zip(*self.memory_usages)
170
+ max_usage = max(usages)
171
+
172
+ return where_s[usages.index(max_usage)], max_usage
173
+
174
+ def AddHandler(self, handler: lggg.Handler, should_hold_messages: bool, /) -> None:
175
+ """"""
176
+ self.should_hold_messages = should_hold_messages
177
+ lggg.Logger.addHandler(self, handler)
178
+
179
+ extension = getattr(handler, "extension", None)
180
+ if extension is None:
181
+ show_memory_usage = False
182
+ else:
183
+ show_memory_usage = getattr(extension, SHOW_MEMORY_ATTR, False)
184
+ if show_memory_usage:
185
+ self.any_handler_shows_memory = True
186
+
187
+ extension = getattr(handler, "extension", handler.name)
188
+ if isinstance(extension, str):
189
+ name = extension
190
+ else:
191
+ name = getattr(extension, "name", "Anonymous")
192
+ self.info(
193
+ f'New handler "{name}" with class "{type(handler).__name__}" and '
194
+ f"level {lggg.getLevelName(handler.level)}",
195
+ **HIDE_WHERE_KWARG,
196
+ )
197
+
198
+ def handle(self, record: lggg.LogRecord, /) -> None:
199
+ """"""
200
+ if (not self.should_hold_messages) and (self.on_hold.__len__() > 0):
201
+ for hold in self.on_hold:
202
+ lggg.Logger.handle(self, hold)
203
+ self.on_hold.clear()
204
+
205
+ record.elapsed_time = ElapsedTime()
206
+
207
+ if self.any_handler_shows_memory or not self.hasHandlers():
208
+ # Memory usage is also added if there are no handlers yet, just in case.
209
+ usage = CurrentMemoryUsage()
210
+ self.memory_usages.append(
211
+ (f"{record.module}.{record.funcName}.{record.lineno}", usage)
212
+ )
213
+
214
+ value, unit = FormattedMemoryUsage(usage, 1)
215
+ record.memory_usage = f"{value}{unit}"
216
+
217
+ date = dttm.now().strftime(DATE_FORMAT)
218
+ if date != self.last_message_date:
219
+ self.last_message_date = date
220
+ # levelno is added for management by lggg.Logger.handle.
221
+ date_record = lggg.makeLogRecord(
222
+ {
223
+ "levelno": lggg.INFO,
224
+ "msg": f"DATE: {date}",
225
+ SHOW_W_RULE_ATTR: True,
226
+ }
227
+ )
228
+ if self.should_hold_messages:
229
+ self.on_hold.append(date_record)
230
+ else:
231
+ lggg.Logger.handle(self, date_record)
232
+
233
+ if self.should_hold_messages:
234
+ self.on_hold.append(record)
235
+ else:
236
+ lggg.Logger.handle(self, record)
237
+
238
+ if self.exit_on_error and (record.levelno in (lggg.ERROR, lggg.CRITICAL)):
239
+ sstm.exit(1)
240
+
241
+ def AddContextLevel(self, new_level: str, /) -> None:
242
+ """"""
243
+ self.context_levels.append(new_level)
244
+
245
+ def AddedContextLevel(self, new_level: str, /) -> logger_t:
246
+ """
247
+ Meant to be used as:
248
+ with self.AddedContextLevel("new level"):
249
+ ...
250
+ """
251
+ self.AddContextLevel(new_level)
252
+ return self
253
+
254
+ def StageIssue(
255
+ self,
256
+ message: str,
257
+ /,
258
+ *,
259
+ actual: h.Any = NOT_PASSED,
260
+ expected: h.Any | None = None,
261
+ ) -> None:
262
+ """"""
263
+ cls = self.__class__
264
+ context = cls.ISSUE_CONTEXT_SEPARATOR.join(self.context_levels)
265
+ issue = NewIssue(
266
+ context, cls.ISSUE_CONTEXT_END, message, actual=actual, expected=expected
267
+ )
268
+ self.staged_issues.append(issue)
269
+
270
+ @property
271
+ def has_staged_issues(self) -> bool:
272
+ """"""
273
+ return self.staged_issues.__len__() > 0
274
+
275
+ def CommitIssues(
276
+ self,
277
+ level: int,
278
+ /,
279
+ *,
280
+ order: order_h = "when",
281
+ ) -> None:
282
+ """"""
283
+ if not self.has_staged_issues:
284
+ return
285
+
286
+ if order not in ORDER:
287
+ raise ValueError(
288
+ FormattedMessage(
289
+ "Invalid commit order",
290
+ actual=order,
291
+ expected=f"One of {str(ORDER)[1:-1]}",
292
+ )
293
+ )
294
+
295
+ if order == "when":
296
+ issues = self.staged_issues
297
+ else: # order == "context"
298
+ issues = sorted(self.staged_issues, key=lambda _elm: _elm.context)
299
+ issues = "\n".join(issues)
300
+
301
+ self.log(level, issues, **HIDE_WHERE_KWARG)
302
+ self.staged_issues.clear()
303
+
304
+ def __enter__(self) -> None:
305
+ """"""
306
+ pass
307
+
308
+ def __exit__(
309
+ self,
310
+ exc_type: Exception | None,
311
+ exc_value: str | None,
312
+ traceback: traceback_t | None,
313
+ /,
314
+ ) -> bool:
315
+ """"""
316
+ _ = self.context_levels.pop()
317
+ return False
318
+
319
+
320
+ def _HandleForWarnings(interceptor: lggg.Logger, /) -> logger_handle_h:
321
+ """"""
322
+
323
+ def handle_p(_: lggg.Logger, record: lggg.LogRecord, /) -> None:
324
+ pieces = WARNING_TYPE_COMPILED_PATTERN.match(record.msg).group
325
+ module = path_t(pieces(1)).stem
326
+ line = pieces(2)
327
+ kind = pieces(3)
328
+ message = pieces(4)
329
+ duplicate = lggg.makeLogRecord(record.__dict__)
330
+ duplicate.msg = f"{kind}: {message}"
331
+ duplicate.module = module
332
+ duplicate.funcName = "<function>"
333
+ duplicate.lineno = line
334
+ interceptor.handle(duplicate)
335
+
336
+ return handle_p
337
+
338
+
339
+ def _HandleForInterceptions(
340
+ intercepted: lggg.Logger, interceptor: lggg.Logger, /
341
+ ) -> logger_handle_h:
342
+ """"""
343
+
344
+ def handle_p(_: lggg.Logger, record: lggg.LogRecord, /) -> None:
345
+ duplicate = lggg.makeLogRecord(record.__dict__)
346
+ duplicate.msg = f"{intercepted.name}{INTERCEPTED_LOG_SEPARATOR}{record.msg}"
347
+ interceptor.handle(duplicate)
348
+
349
+ return handle_p
logger_36/version.py CHANGED
@@ -29,4 +29,4 @@
29
29
  # The fact that you are presently reading this means that you have had
30
30
  # knowledge of the CeCILL license and that you accept its terms.
31
31
 
32
- __version__ = "2024.1"
32
+ __version__ = "2024.2"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: logger-36
3
- Version: 2024.1
3
+ Version: 2024.2
4
4
  Summary: Simple logger using rich_
5
5
  Home-page: https://src.koda.cnrs.fr/eric.debreuve/logger-36/
6
6
  Author: Eric Debreuve
@@ -16,7 +16,6 @@ Classifier: Programming Language :: Python :: 3.10
16
16
  Classifier: Development Status :: 4 - Beta
17
17
  Requires-Python: >=3.10
18
18
  Description-Content-Type: text/x-rst
19
- Requires-Dist: rich
20
19
 
21
20
  ..
22
21
  Copyright CNRS/Inria/UCA
@@ -0,0 +1,39 @@
1
+ logger_36/__init__.py,sha256=-VGyte6TD6SWU4jBXUjur_xU1R1Asha5KXEwDNmGJ6Q,1756
2
+ logger_36/instance.py,sha256=NQlDAyXV3TNekX9xj9V7JMePmsa2DWnTDaVzh5dcyGM,1616
3
+ logger_36/main.py,sha256=hj3hctMBHJbPWw1078tJ_zOU-6-kEGCzMgHwpWY5ElA,6134
4
+ logger_36/version.py,sha256=k9JK70ov-I4eRm2xjcPqT7aryHlmg6XXYSEUPtNqgU8,1575
5
+ logger_36/catalog/config/console_rich.py,sha256=jJnYXPDsMCTu8zny2X3NdeyKFCfhJupberqIBxyv3LA,2030
6
+ logger_36/catalog/handler/console.py,sha256=PnaCWJsXN-x_-X8i-4o4HWys-7K0A83s4kIdtmDz3AQ,3092
7
+ logger_36/catalog/handler/console_rich.py,sha256=YqKyKwHoYCEVnW1S87NDu3ReTCIzSdYgC-20-813TFQ,5395
8
+ logger_36/catalog/handler/file.py,sha256=BAxA-ZQAikmH0R9Ia3mbSXf-Z60-FfA4ElOVjjmanS0,3507
9
+ logger_36/catalog/handler/generic.py,sha256=1pAmP5vOxBPWhpqoBRDNIc3q14dIDsj7JbX-VqcgUbM,5931
10
+ logger_36/catalog/logging/chronos.py,sha256=5SWyRUhwwKeJg3NPf9jkCqtKc7b_4x58Slbq2iMA8kE,1814
11
+ logger_36/catalog/logging/gpu.py,sha256=OpSQK0paA-xzxeWTKAx9QUqEytFyYvHgiVvWe97-rZ8,2465
12
+ logger_36/catalog/logging/memory.py,sha256=50wX25rXnI8NLlr3gp6793hKUE988CACIXVLMQRUcMs,4038
13
+ logger_36/catalog/logging/system.py,sha256=BzJLBvhyIE5nfUZJo4f1PPmu47YufVyin5ssX9GpXVU,2447
14
+ logger_36/config/issue.py,sha256=cAv4hbikcATtEwMtjgsOcPij8Ylv4XE2dg5hcqaw0FU,1574
15
+ logger_36/config/memory.py,sha256=_cJE_ku9adDk2Pb9jvyQIRilvYRS2uofB8hfTucRrwo,1587
16
+ logger_36/config/message.py,sha256=8AzmioSYDuguK1KN1a84yX0EE-1AnMb7XYgoImtorEA,2056
17
+ logger_36/config/system.py,sha256=d4dddB8IknyGmvOmUdi9Bunc60mEXjwB3AvjyrpCKrY,1847
18
+ logger_36/constant/generic.py,sha256=Tdo8wbhde6hcoB8Xv8AXIkFm4EimOfadDEAacf0j8OE,1614
19
+ logger_36/constant/handler.py,sha256=YoCxN1MTl1c3VuUETjvFKyW_4XM6vwb6BdCUk4Y4_VQ,1681
20
+ logger_36/constant/issue.py,sha256=nq-JDE9pKoshYkXnS-F8R4dlCUCKFQR5w7SwNp-iz30,1656
21
+ logger_36/constant/logger.py,sha256=ze64rQ0oDoC-r0EvX-6qmVN41cG9_vGr7kxrGjtpFvk,2150
22
+ logger_36/constant/memory.py,sha256=9bKK_L4TfNB-Q34qIeTDtDLhQd3p9N0ZHpAmRTXZgJI,1795
23
+ logger_36/constant/message.py,sha256=vT9AukWubfwuQIO10eeR0EMO0Sov9-vLPj95Mg4WPsA,2084
24
+ logger_36/constant/record.py,sha256=79NZCveVyCvwIWOMGmFrdMXsOLdJullguPbY4TB8EZY,1681
25
+ logger_36/constant/system.py,sha256=CLfopBgUhkegE-VQxGRxPMJGanIcK6vkhix8ZzEG5V0,1800
26
+ logger_36/task/inspection.py,sha256=Ozgj_2iQqHEmn6VQPh2rAZJ5233SD1WotFNUOXvukW4,4397
27
+ logger_36/task/storage.py,sha256=y9q8RS_uwxVs89pwecdB7018-4qsgPpAqocAJkhMh-k,5060
28
+ logger_36/task/format/memory.py,sha256=ZeDM6pCMRh81iSifQjiaYHVmKzzR5JhVTqAKd3Dju0U,3610
29
+ logger_36/task/format/message.py,sha256=XAqdR8NWFo-EnzUzaRBFO6jyYb0Su7jCgVQ1HLelxHs,3511
30
+ logger_36/task/format/rule.py,sha256=elNk65Y7HT42otObwfds-DwGwfZae0A77nDPCZuMcGE,1968
31
+ logger_36/task/measure/chronos.py,sha256=qT80jxZm_dAg2P4WkfU0L3PRvRojT21Ps3DtNYqGdrg,2253
32
+ logger_36/task/measure/memory.py,sha256=1f1X-XHd_58LJYJ0Ok5TGIagnf0k5F39IFqWHN2Ojas,1874
33
+ logger_36/type/extension.py,sha256=fsYx0wT1bR6DtpM2VnaxsM0MFv2vBLROgRSCs4duasY,5198
34
+ logger_36/type/issue.py,sha256=4D4e047sHhF3r8YtDj3k50iC5UaSUpXEKMaD9isjspc,2139
35
+ logger_36/type/logger.py,sha256=eIQQiuhicz73ipz-94qGcwxe34sP_HxSgWnFxk78owI,12245
36
+ logger_36-2024.2.dist-info/METADATA,sha256=OFiqvDFojFn_Nog71KVNtDBz_WespEDNYh3u5Ur8ChU,4221
37
+ logger_36-2024.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
38
+ logger_36-2024.2.dist-info/top_level.txt,sha256=sM95BTMWmslEEgR_1pzwZsOeSp8C_QBiu8ImbFr0XLc,10
39
+ logger_36-2024.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.42.0)
2
+ Generator: bdist_wheel (0.43.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5