logger-36 2025.20__py3-none-any.whl → 2025.21__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/type/logger.py CHANGED
@@ -70,12 +70,12 @@ class logger_t(base_t):
70
70
  intercepted_wrn_handle: When warning interception is on, this stores the original
71
71
  "handle" method of the Python warning logger.
72
72
 
73
- _should_activate_log_interceptions: Loggers instantiated after a logger_t logger will
74
- be missed by an early call of ToggleLogInterceptions. Therefore, passing True for
75
- activate_log_interceptions only sets _should_activate_log_interceptions to True,
73
+ _should_activate_log_interceptions: Loggers instantiated after a logger_t logger
74
+ will be missed by an early call of ToggleLogInterceptions. Therefore, passing True
75
+ for activate_log_interceptions only sets _should_activate_log_interceptions to True,
76
76
  which is later checked in AddHandler to effectively call ToggleLogInterceptions if
77
- _should_hold_messages is False (which normally indicates that the handler about to be
78
- added is the last one).
77
+ _should_hold_messages is False (which normally indicates that the handler about to
78
+ be added is the last one).
79
79
 
80
80
  _should_hold_messages: Must not be False until at least one handler has been added.
81
81
  """
@@ -165,12 +165,17 @@ class logger_t(base_t):
165
165
  self.setLevel(level_)
166
166
  self.propagate = False # Part of base_t.
167
167
 
168
- if self.should_record_messages:
169
- self.ActivateMessageRecording()
168
+ if self.exit_on_error:
169
+ self.exit_on_critical = True
170
170
 
171
171
  for level_id in l.getLevelNamesMapping().values():
172
172
  self.events[level_id] = 0
173
173
 
174
+ if self.should_record_messages:
175
+ self.ActivateMessageRecording()
176
+
177
+ self.info(f'New logger "{self.name}" for "{PROJECT_FILE_RELATIVE}"')
178
+
174
179
  if activate_wrn_interceptions:
175
180
  self.ToggleWarningInterceptions(True)
176
181
  if activate_log_interceptions:
@@ -178,24 +183,16 @@ class logger_t(base_t):
178
183
  if activate_exc_interceptions:
179
184
  self.ToggleExceptionInterceptions(True)
180
185
 
181
- if self.exit_on_error:
182
- self.exit_on_critical = True
183
-
184
186
  if self.should_watch_memory_usage and not CanCheckMemoryUsage():
185
187
  self.should_watch_memory_usage = False
186
188
  if _MEMORY_MEASURE_ERROR is not None:
187
189
  s.__stderr__.write(_MEMORY_MEASURE_ERROR + "\n")
188
190
  _MEMORY_MEASURE_ERROR = None
189
191
 
190
- self.info(f'New logger "{self.name}" for "{PROJECT_FILE_RELATIVE}"')
191
-
192
192
  def handle(self, record: l.LogRecord, /) -> None:
193
193
  """"""
194
194
  elapsed_time, now = ElapsedTime(should_return_now=True)
195
195
 
196
- if (self._on_hold.__len__() > 0) and not self._should_hold_messages:
197
- self._FlushRecordsOnHold()
198
-
199
196
  if (date := now.date()) != self.last_message_date:
200
197
  self._AcknowledgeDateChange(date)
201
198
 
@@ -378,12 +375,19 @@ class logger_t(base_t):
378
375
  should_still_hold_messages: bool = False,
379
376
  **kwargs,
380
377
  ) -> None:
381
- """"""
382
- if (not should_still_hold_messages) and self._should_activate_log_interceptions:
383
- self.ToggleLogInterceptions(True)
384
- self._should_activate_log_interceptions = False
378
+ """
379
+ Silently ignores re-holding request after un-holding.
380
+ """
381
+ should_flush_on_hold = False
382
+ new_handler_warning = ""
383
+ if self._should_hold_messages and not should_still_hold_messages:
384
+ if self._should_activate_log_interceptions:
385
+ self.ToggleLogInterceptions(True)
386
+ self._should_activate_log_interceptions = False
385
387
 
386
- self._should_hold_messages = should_still_hold_messages
388
+ self._should_hold_messages = False
389
+ should_flush_on_hold = True
390
+ new_handler_warning = "\n(Handlers added from now on will miss above logs.)"
387
391
 
388
392
  if isinstance(handler_t_or_handler, type):
389
393
  handler = handler_t_or_handler.New(
@@ -393,12 +397,17 @@ class logger_t(base_t):
393
397
  handler = handler_t_or_handler
394
398
  base_t.addHandler(self, handler)
395
399
 
400
+ # Wait until after the handler has been added to flush messages on hold.
401
+ if should_flush_on_hold:
402
+ self._FlushRecordsOnHold()
403
+
396
404
  path = getattr(handler, "baseFilename", "")
397
405
  if isinstance(path, path_t) or (path.__len__() > 0):
398
406
  path = f"\nPath: {path}"
399
407
  self.info(
400
408
  f'New handler "{handler.name}" of type "{type(handler).__name__}" and '
401
409
  f"level {handler.level}={l.getLevelName(handler.level)}{path}"
410
+ f"{new_handler_warning}"
402
411
  )
403
412
 
404
413
  def MakeMonochrome(self) -> None:
logger_36/version.py CHANGED
@@ -4,7 +4,7 @@ Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
4
4
  SEE COPYRIGHT NOTICE BELOW
5
5
  """
6
6
 
7
- __version__ = "2025.20"
7
+ __version__ = "2025.21"
8
8
 
9
9
  """
10
10
  COPYRIGHT NOTICE
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: logger-36
3
- Version: 2025.20
3
+ Version: 2025.21
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
@@ -1,5 +1,5 @@
1
1
  logger_36/__init__.py,sha256=mK6AD0eWI2Sk42oxleTvsxzYJ28FbHK5WNkpLgAhnNE,2129
2
- logger_36/version.py,sha256=vDO1d9-QYkQ8yZUGGG46kdG9NRQx6ONSvh6-E6JGHu4,1680
2
+ logger_36/version.py,sha256=uq-1uJ3Ttvm7hNAwg0S3T103Mh6UIamgGGIWFao8YLI,1680
3
3
  logger_36/api/content.py,sha256=DuT4UX4r_1DTXzuuRD-tvsTZk5X-Nj11loBKhuWOMw0,1791
4
4
  logger_36/api/gpu.py,sha256=NNs1IvQ7bh8Dppm8O8K2YLWbm4rogc3Ie_-D6xzkX3g,1726
5
5
  logger_36/api/memory.py,sha256=vOY4cTTrC3u7L0OrKXdPNlsCahYjCrY4h7iqpGZv9kU,2217
@@ -44,9 +44,9 @@ logger_36/task/measure/chronos.py,sha256=7ijMZgP4EP18HbLV2yCxpNpRS9724Wyk523f-nk
44
44
  logger_36/task/measure/memory.py,sha256=kkPHEIUTUhkCOLrAt01eLJLnsnkl0nFPNhFZdIB_JAw,1991
45
45
  logger_36/type/handler.py,sha256=ChxP1j9PXLmoiNcsOdxI4bYVdr75v7HeCWp_iYJ2WNY,6602
46
46
  logger_36/type/issue.py,sha256=QHAYf7QgrjJUtF2D46z6X630qTgeP_0FE5hIwf54RsE,2688
47
- logger_36/type/logger.py,sha256=tWdexeJT9IrxKK2NQmnHi1WVmN16xR8RNZPMc__SWBs,25447
47
+ logger_36/type/logger.py,sha256=-cEc56RRpYkXaoDjI7PF7q14Mamdc4zu3DmQ-lRjIn8,25823
48
48
  logger_36/type/loggers.py,sha256=7EX7Sg_RlduBjdfFlNZmUfNeDloH1xU30Rdkg_-rXh8,3172
49
- logger_36-2025.20.dist-info/METADATA,sha256=On7rI0r81M6ehWSyX7ZPiBKYVZoLqMPj-1VJWRuSd50,6529
50
- logger_36-2025.20.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
51
- logger_36-2025.20.dist-info/top_level.txt,sha256=sM95BTMWmslEEgR_1pzwZsOeSp8C_QBiu8ImbFr0XLc,10
52
- logger_36-2025.20.dist-info/RECORD,,
49
+ logger_36-2025.21.dist-info/METADATA,sha256=bTX5e3Xn8lko_GnzpFd7XnE60aNUv6V_9JyoLwzE2G4,6529
50
+ logger_36-2025.21.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
51
+ logger_36-2025.21.dist-info/top_level.txt,sha256=sM95BTMWmslEEgR_1pzwZsOeSp8C_QBiu8ImbFr0XLc,10
52
+ logger_36-2025.21.dist-info/RECORD,,