logger-36 2024.10__py3-none-any.whl → 2024.11__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.
@@ -29,6 +29,9 @@
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
+ """
33
+ Colors: See https://rich.readthedocs.io/en/stable/appendix/colors.html.
34
+ """
32
35
  import logging as lggg
33
36
 
34
37
  from rich.color import Color as color_t
@@ -42,7 +45,7 @@ LEVEL_COLOR: dict[int, str | style_t] = {
42
45
  lggg.ERROR: "orange1",
43
46
  lggg.CRITICAL: "red",
44
47
  }
45
- ACTUAL_COLOR: str = "red"
48
+ ACTUAL_COLOR: str = "indian_red"
46
49
  EXPECTED_COLOR: str = "green"
47
50
  ELAPSED_TIME_COLOR: str = "green"
48
51
 
@@ -33,3 +33,5 @@ import typing as h
33
33
 
34
34
  storage_units_h = h.Literal["b", "k", "m", "g", "a"]
35
35
  STORAGE_UNITS: tuple[str, ...] = h.get_args(storage_units_h)
36
+
37
+ UNKNOWN_MEMORY_USAGE = -1
@@ -33,6 +33,8 @@ import dataclasses as dtcl
33
33
  import logging as lggg
34
34
  import sys as sstm
35
35
  import typing as h
36
+ from os import sep as FOLDER_SEPARATOR
37
+ from pathlib import Path as path_t
36
38
 
37
39
  from logger_36.config.message import TIME_FORMAT, WHERE_FORMAT
38
40
  from logger_36.constant.error import MEMORY_MEASURE_ERROR
@@ -123,8 +125,20 @@ class handler_extension_t:
123
125
  if hide_where:
124
126
  record.where = ""
125
127
  else:
128
+ module = path_t(record.pathname)
129
+ path_was_found = False
130
+ for path in sstm.path:
131
+ if module.is_relative_to(path):
132
+ module = module.relative_to(path)
133
+ path_was_found = True
134
+ break
135
+ if path_was_found:
136
+ module = str(module.parent / module.stem)
137
+ module = module.replace(FOLDER_SEPARATOR, ".")
138
+ else:
139
+ module = record.module
126
140
  record.where = WHERE_FORMAT.format(
127
- module=record.module, funcName=record.funcName, lineno=record.lineno
141
+ module=module, funcName=record.funcName, lineno=record.lineno
128
142
  )
129
143
  first_line = self.FormattedRecord(record).replace("\t", " ")
130
144
 
logger_36/type/logger.py CHANGED
@@ -52,6 +52,7 @@ from logger_36.constant.logger import (
52
52
  WARNING_TYPE_COMPILED_PATTERN,
53
53
  logger_handle_h,
54
54
  )
55
+ from logger_36.constant.memory import UNKNOWN_MEMORY_USAGE
55
56
  from logger_36.constant.record import SHOW_MEMORY_ATTR, SHOW_W_RULE_ATTR
56
57
  from logger_36.task.format.memory import (
57
58
  FormattedUsageWithAutoUnit as FormattedMemoryUsage,
@@ -103,7 +104,6 @@ class logger_t(lggg.Logger):
103
104
  """
104
105
  if self.intercepted_wrn_handle is None:
105
106
  logger = lggg.getLogger(WARNING_LOGGER_NAME)
106
-
107
107
  self.intercepted_wrn_handle = logger.handle
108
108
  logger.handle = t.MethodType(_HandleForWarnings(self), logger)
109
109
 
@@ -114,7 +114,6 @@ class logger_t(lggg.Logger):
114
114
  """"""
115
115
  if self.intercepted_wrn_handle is not None:
116
116
  logger = lggg.getLogger(WARNING_LOGGER_NAME)
117
-
118
117
  logger.handle = self.intercepted_wrn_handle
119
118
  self.intercepted_wrn_handle = None
120
119
 
@@ -146,8 +145,9 @@ class logger_t(lggg.Logger):
146
145
 
147
146
  intercepted = sorted(self.intercepted_log_handles.keys())
148
147
  if intercepted.__len__() > 0:
148
+ as_str = ", ".join(intercepted)
149
149
  self.info(
150
- f"Now Intercepting LOGs from: {str(intercepted)[1:-1]}",
150
+ f"Now Intercepting LOGs from: {as_str}",
151
151
  **HIDE_WHERE_KWARG,
152
152
  )
153
153
  elif self.intercepted_log_handles.__len__() > 0:
@@ -160,15 +160,20 @@ class logger_t(lggg.Logger):
160
160
  @property
161
161
  def max_memory_usage(self) -> int:
162
162
  """"""
163
- return max(tuple(zip(*self.memory_usages))[1])
163
+ if self.memory_usages.__len__() > 0:
164
+ return max(tuple(zip(*self.memory_usages))[1])
165
+ return UNKNOWN_MEMORY_USAGE
164
166
 
165
167
  @property
166
168
  def max_memory_usage_full(self) -> tuple[str, int]:
167
169
  """"""
168
- where_s, usages = zip(*self.memory_usages)
169
- max_usage = max(usages)
170
+ if self.memory_usages.__len__() > 0:
171
+ where_s, usages = zip(*self.memory_usages)
172
+ max_usage = max(usages)
170
173
 
171
- return where_s[usages.index(max_usage)], max_usage
174
+ return where_s[usages.index(max_usage)], max_usage
175
+
176
+ return "?", UNKNOWN_MEMORY_USAGE
172
177
 
173
178
  def AddHandler(self, handler: lggg.Handler, should_hold_messages: bool, /) -> None:
174
179
  """"""
@@ -309,7 +314,7 @@ class logger_t(lggg.Logger):
309
314
  print("\n".join(lines), file=sstm.stderr)
310
315
  sstm.exit(1)
311
316
 
312
- self.log(level, issues, **HIDE_WHERE_KWARG)
317
+ self.log(level, issues, stacklevel=2)
313
318
  self.staged_issues.clear()
314
319
 
315
320
  def __enter__(self) -> None:
@@ -332,16 +337,25 @@ def _HandleForWarnings(interceptor: lggg.Logger, /) -> logger_handle_h:
332
337
  """"""
333
338
 
334
339
  def handle_p(_: lggg.Logger, record: lggg.LogRecord, /) -> None:
335
- pieces = WARNING_TYPE_COMPILED_PATTERN.match(record.msg).group
336
- module = path_t(pieces(1)).stem
337
- line = pieces(2)
338
- kind = pieces(3)
339
- message = pieces(4)
340
+ pieces = WARNING_TYPE_COMPILED_PATTERN.match(record.msg)
341
+ if pieces is None:
342
+ # The warning message does not follow the default format.
343
+ interceptor.handle(record)
344
+ return
345
+
346
+ GetPiece = pieces.group
347
+ path = GetPiece(1)
348
+ line = GetPiece(2)
349
+ kind = GetPiece(3)
350
+ message = GetPiece(4)
351
+
340
352
  duplicate = lggg.makeLogRecord(record.__dict__)
341
353
  duplicate.msg = f"{kind}: {message}"
342
- duplicate.module = module
343
- duplicate.funcName = "<function>"
354
+ duplicate.pathname = path
355
+ duplicate.module = path_t(path).stem
356
+ duplicate.funcName = "?"
344
357
  duplicate.lineno = line
358
+
345
359
  interceptor.handle(duplicate)
346
360
 
347
361
  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.10"
32
+ __version__ = "2024.11"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: logger-36
3
- Version: 2024.10
3
+ Version: 2024.11
4
4
  Summary: Simple logger with a catalog of handlers
5
5
  Home-page: https://src.koda.cnrs.fr/eric.debreuve/logger-36/
6
6
  Author: Eric Debreuve
@@ -60,7 +60,7 @@ Description-Content-Type: text/x-rst
60
60
  .. _DOCUMENTATION_URL: https://src.koda.cnrs.fr/eric.debreuve/logger-36/-/wikis/home
61
61
 
62
62
  .. |DEPENDENCIES_MANDATORY| replace:: None
63
- .. |DEPENDENCIES_OPTIONAL| replace:: psutil, rich
63
+ .. |DEPENDENCIES_OPTIONAL| replace:: psutil, rich, tensorflow, tensorrt
64
64
 
65
65
 
66
66
 
@@ -1,8 +1,8 @@
1
1
  logger_36/__init__.py,sha256=67ZAWtUx9Qy8Yn-tLQkOIEO6Z9U-8jhfm-tqNjjeFPU,1758
2
2
  logger_36/instance.py,sha256=wAVty29f24SCs4FRL600QySlA_WeLUM78p4t_Ni-LzA,1618
3
3
  logger_36/main.py,sha256=peXqcSDTrJhlKQkxSmum94BUJ8pIrtWTfvV9hUXp_pU,6558
4
- logger_36/version.py,sha256=yjlxOIUGKNxpL_YRAf-O7XKKVh2jWnnOqDCS1DTeuMg,1578
5
- logger_36/catalog/config/console_rich.py,sha256=sxxq6iPzlACCMUlDGhDIcDFWY3o6OR5rlg4uOwjsd30,2032
4
+ logger_36/version.py,sha256=VPjT_M7RlFPu1ODt109-IVr0VpM4GYTOMO2BBrkKt0A,1578
5
+ logger_36/catalog/config/console_rich.py,sha256=XKRKJx_5dxp4mgan1D-u_qrQos-pezRccqKsnmn-ook,2119
6
6
  logger_36/catalog/handler/console.py,sha256=dm2-_1ZXUd6Gl1uyJaapPhUldzkEZ2fOlgeH8gxmpSs,3094
7
7
  logger_36/catalog/handler/console_rich.py,sha256=TMP9fupSY8OdGb3jeMAeSLjOssJBgcdwkTDo4Enud5U,6513
8
8
  logger_36/catalog/handler/file.py,sha256=tBShoy37F3riXDQc802feKzdpHQj5F3vqKaq211I1WI,3509
@@ -20,7 +20,7 @@ logger_36/constant/generic.py,sha256=s0WHW-R_Eu2doDMoGERX3MtfCHmIW6uDjrDt_qP5MLA
20
20
  logger_36/constant/handler.py,sha256=Iw4Pnr5ZUMIeRSA0netupu4icDWoMYKLZRW7_JWbwiI,1683
21
21
  logger_36/constant/issue.py,sha256=08BxREcVT0XnIFV3SrRQNd2uEOtnOP9VtscvRYXz1W4,1658
22
22
  logger_36/constant/logger.py,sha256=-dE218OMVyIgHIIEiXgJ0a4p_76CJk6ULihU0MvJO1g,2152
23
- logger_36/constant/memory.py,sha256=-sgLnUTPsI-e8OwaVFO70Jd2Fl5Fh6ISu_TNuUhV0sM,1688
23
+ logger_36/constant/memory.py,sha256=gjQbcJt-bf6LluxPy40nY-UFJRQ7Z-zX1xi4BKTw9hI,1715
24
24
  logger_36/constant/message.py,sha256=tklw8IIT8f29lmmkk-se3GM9SKzRvmdIEJTX9ZQu-dc,2086
25
25
  logger_36/constant/record.py,sha256=oEwG4gjhN-Al_1cTjDLdvS_qYKUy4zkR5QUkYocT7eU,1683
26
26
  logger_36/constant/system.py,sha256=dlEU4q-hSFAO6aAa6m_yCGfBwNH5AHTyVZbRFTZ0U0U,1802
@@ -31,10 +31,10 @@ logger_36/task/format/message.py,sha256=91CCgH7umLHUV_YRf4AyOsYZTgNVOvQSODqXO1wJ
31
31
  logger_36/task/format/rule.py,sha256=cq4jl_ZCb8m7QoX8mWevXhy1hgwncLpc-9woKoT7m24,1970
32
32
  logger_36/task/measure/chronos.py,sha256=7xZskYEXQCPDypmnlhn4KDCBB1v3eL1OE_sv-l3n8Do,2255
33
33
  logger_36/task/measure/memory.py,sha256=aichGI-iCeE3Z4Y8AmWGdal2931IMdcdv4VgCeDLBoI,1876
34
- logger_36/type/extension.py,sha256=P93oObv54OLqRCCR-kmgxosvLKTWMwZwoXNvPMqv6-M,5383
34
+ logger_36/type/extension.py,sha256=W4sS48WiUUQStWq7rt8gZxtilElpfNSVc6cG3j8kfDA,5992
35
35
  logger_36/type/issue.py,sha256=OnkBKRTMsHvZ-2aLQWtBzGSWMTVs_4ermg71Ygcs0w8,2153
36
- logger_36/type/logger.py,sha256=eU5BhAETXpUTyY-2MoAOxsgmqaN537TgQkSnNABjoUg,12768
37
- logger_36-2024.10.dist-info/METADATA,sha256=xyrCpVKqytvaSQeBroLKYj7a4rIlrx_DG_qhCQsk3HI,5570
38
- logger_36-2024.10.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
39
- logger_36-2024.10.dist-info/top_level.txt,sha256=sM95BTMWmslEEgR_1pzwZsOeSp8C_QBiu8ImbFr0XLc,10
40
- logger_36-2024.10.dist-info/RECORD,,
36
+ logger_36/type/logger.py,sha256=FAaYj3wH9R9mhLNZLkYxjWwviWjDLBp4EilbHZnORJM,13248
37
+ logger_36-2024.11.dist-info/METADATA,sha256=JBX4N-jAY_UNB4PpM9VrABAqQx1RA-ZfFyFfFos_T5k,5592
38
+ logger_36-2024.11.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
39
+ logger_36-2024.11.dist-info/top_level.txt,sha256=sM95BTMWmslEEgR_1pzwZsOeSp8C_QBiu8ImbFr0XLc,10
40
+ logger_36-2024.11.dist-info/RECORD,,