logger-36 2025.25__py3-none-any.whl → 2025.27__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.
@@ -7,14 +7,6 @@ SEE COPYRIGHT NOTICE BELOW
7
7
  import logging as l
8
8
  import typing as h
9
9
 
10
- from rich.console import Console as console_t # noqa
11
- from rich.console import RenderableType as renderable_t # noqa
12
- from rich.markup import escape as EscapedVersion # noqa
13
- from rich.rule import Rule as rule_t # noqa
14
- from rich.style import Style as style_t # noqa
15
- from rich.text import Text as text_t # noqa
16
- from rich.traceback import install as InstallTracebackHandler # noqa
17
-
18
10
  from logger_36.catalog.config.console_rich import (
19
11
  ACTUAL_COLOR,
20
12
  ALTERNATIVE_BACKGROUND_FOR_DARK,
@@ -29,6 +21,13 @@ from logger_36.config.message import ACTUAL_PATTERNS, EXPECTED_PATTERNS
29
21
  from logger_36.constant.message import CONTEXT_LENGTH
30
22
  from logger_36.constant.record import HAS_ACTUAL_EXPECTED_ATTR
31
23
  from logger_36.type.handler import non_file_handler_t as base_t
24
+ from rich.console import Console as console_t # noqa
25
+ from rich.console import RenderableType as renderable_t # noqa
26
+ from rich.markup import escape as EscapedVersion # noqa
27
+ from rich.rule import Rule as rule_t # noqa
28
+ from rich.style import Style as style_t # noqa
29
+ from rich.text import Text as text_t # noqa
30
+ from rich.traceback import install as InstallTracebackHandler # noqa
32
31
 
33
32
  _COMMON_TRACEBACK_ARGUMENTS = ("theme", "width")
34
33
  _EXCLUSIVE_TRACEBACK_ARGUMENTS = (
@@ -105,7 +104,7 @@ class console_rich_handler_t(base_t):
105
104
 
106
105
  def Rule(self, /, *, text: str | None = None, color: str = "black") -> str | rule_t:
107
106
  """"""
108
- if text is None:
107
+ if text in (None, ""):
109
108
  return rule_t(style=color)
110
109
  return rule_t(title=text_t(text, style=f"bold {color}"), style=color)
111
110
 
@@ -94,7 +94,7 @@ class generic_handler_t(base_t):
94
94
  def Rule(self, /, *, text: str | None = None, color: str = "black") -> str | rule_t:
95
95
  """"""
96
96
  if self.is_rich:
97
- if text is None:
97
+ if text in (None, ""):
98
98
  return rule_t(style=color)
99
99
  return rule_t(title=text_t(text, style=f"bold {color}"), style=color)
100
100
 
@@ -11,9 +11,7 @@ def WrappedLines(lines: list[str], message_width: int, /) -> list[str]:
11
11
 
12
12
  for line in lines:
13
13
  while line.__len__() > message_width:
14
- if all(
15
- _ != " " for _ in line[(message_width - 1) : (message_width + 1)]
16
- ):
14
+ if all(_ != " " for _ in line[(message_width - 1) : (message_width + 1)]):
17
15
  if line[message_width - 2] == " ":
18
16
  piece, line = (
19
17
  line[: (message_width - 2)].rstrip(),
logger_36/type/handler.py CHANGED
@@ -91,7 +91,7 @@ class extension_t:
91
91
  """
92
92
  Return type hint h.Any: For Rich, for example.
93
93
  """
94
- if text is None:
94
+ if text in (None, ""):
95
95
  if self.message_width > 0:
96
96
  return self.message_width * RULE_CHARACTER
97
97
  return DEFAULT_RULE
logger_36/type/logger.py CHANGED
@@ -9,7 +9,6 @@ import inspect as e
9
9
  import logging as l
10
10
  import multiprocessing as prll
11
11
  import sys as s
12
- import textwrap as text
13
12
  import threading as thrd
14
13
  import traceback as tcbk
15
14
  import types as t
@@ -41,7 +40,7 @@ from logger_36.constant.chronos import DATE_ORIGIN, DATE_TIME_ORIGIN
41
40
  from logger_36.constant.issue import ISSUE_LEVEL_SEPARATOR, ORDER, order_h
42
41
  from logger_36.constant.logger import WARNING_LOGGER_NAME, WARNING_TYPE_COMPILED_PATTERN
43
42
  from logger_36.constant.memory import UNKNOWN_MEMORY_USAGE
44
- from logger_36.constant.message import LINE_INDENT, expected_op_h
43
+ from logger_36.constant.message import expected_op_h
45
44
  from logger_36.constant.path import USER_FOLDER, LAUNCH_ROOT_FILE_relative
46
45
  from logger_36.constant.record import (
47
46
  HAS_ACTUAL_EXPECTED_ATTR,
@@ -56,7 +55,6 @@ from logger_36.extension.sentinel import NOT_PASSED
56
55
  from logger_36.task.format.message import MessageWithActualExpected
57
56
  from logger_36.task.measure.chronos import FormattedElapsedTime
58
57
  from logger_36.task.measure.memory import CurrentUsage as CurrentMemoryUsage
59
- from logger_36.type.handler import extension_t as handler_extension_t
60
58
  from logger_36.type.handler import handler_h as base_handler_h
61
59
  from logger_36.type.issue import NewIssue, issue_t
62
60
 
@@ -449,7 +447,7 @@ class logger_t(base_t):
449
447
  """
450
448
  For a print-like calling for print-based debugging.
451
449
  """
452
- separator = kwargs.get("separator", " ")
450
+ separator = kwargs.pop("separator", " ")
453
451
 
454
452
  frame = e.stack(context=0)[1][0] # 1=caller.
455
453
  details = e.getframeinfo(frame, context=0)
@@ -458,7 +456,10 @@ class logger_t(base_t):
458
456
  path = path.relative_to(USER_FOLDER)
459
457
  where = f"{str(path.with_suffix(''))}:{details.function}:{details.lineno}"
460
458
 
461
- self.info(separator.join(map(str, args)) + f"\n{WHERE_SEPARATOR} " + where)
459
+ self.info(
460
+ separator.join(map(str, args)) + f"\n{WHERE_SEPARATOR} " + where,
461
+ extra=kwargs,
462
+ )
462
463
 
463
464
  def Log(
464
465
  self,
@@ -471,6 +472,7 @@ class logger_t(base_t):
471
472
  expected_is_choices: bool = False,
472
473
  expected_op: expected_op_h = "=",
473
474
  with_final_dot: bool = True,
475
+ **extra,
474
476
  ) -> None:
475
477
  """"""
476
478
  if isinstance(level, str):
@@ -483,23 +485,12 @@ class logger_t(base_t):
483
485
  expected_op=expected_op,
484
486
  with_final_dot=with_final_dot,
485
487
  )
486
- if has_actual_expected:
487
- extra = {HAS_ACTUAL_EXPECTED_ATTR: True}
488
- else:
489
- extra = {}
488
+ extra[HAS_ACTUAL_EXPECTED_ATTR] = has_actual_expected
490
489
  self.log(level, message, extra=extra)
491
490
 
492
- def LogAsIs(self, message: str, /, *, indented: bool = False) -> None:
491
+ def LogAsIs(self, message: str, /) -> None:
493
492
  """"""
494
- if indented:
495
- message = text.indent(message, LINE_INDENT)
496
-
497
- for handler in self.handlers:
498
- EmitMessage = getattr(
499
- handler, handler_extension_t.EmitMessage.__name__, None
500
- )
501
- if EmitMessage is not None:
502
- EmitMessage(message)
493
+ self.log(l.INFO, message, extra={SHOW_WHEN_ATTR: False, SHOW_WHERE_ATTR: False})
503
494
 
504
495
  info_raw = LogAsIs # To follow the convention of the logging methods info, error...
505
496
 
@@ -539,10 +530,22 @@ class logger_t(base_t):
539
530
  self, /, *, message: str | None = None, color: str = "white"
540
531
  ) -> None:
541
532
  """"""
542
- for handler in self.handlers:
543
- EmitRule = getattr(handler, handler_extension_t.EmitRule.__name__, None)
544
- if EmitRule is not None:
545
- EmitRule(text=message, color=color)
533
+ if message is None:
534
+ message = ""
535
+ record = l.makeLogRecord(
536
+ {
537
+ "name": self.name,
538
+ "levelno": l.INFO, # For management by logging.Logger.handle.
539
+ "msg": message,
540
+ SHOW_W_RULE_ATTR: True,
541
+ }
542
+ )
543
+ base_t.handle(self, record)
544
+ # emit_rule_name = handler_extension_t.EmitRule.__name__
545
+ # for handler in self.handlers:
546
+ # EmitRule = getattr(handler, emit_rule_name, None)
547
+ # if EmitRule is not None:
548
+ # EmitRule(text=message, color=color)
546
549
 
547
550
  def AddContextLevel(self, new_level: str, /) -> None:
548
551
  """"""
@@ -698,9 +701,11 @@ class logger_t(base_t):
698
701
 
699
702
  def __del__(self) -> None:
700
703
  """"""
701
- assert prll.current_process().name == MAIN_PROCESS_NAME
702
-
703
- if self.log_server is not None:
704
+ if (
705
+ (prll.current_process is not None)
706
+ and (prll.current_process().name == MAIN_PROCESS_NAME)
707
+ and (self.log_server is not None)
708
+ ):
704
709
  self.log_server.stop()
705
710
 
706
711
 
logger_36/type/loggers.py CHANGED
@@ -22,7 +22,6 @@ class loggers_t(dict[h.Hashable, logger_t]):
22
22
  *,
23
23
  name: str | None = None,
24
24
  level: int = l.NOTSET,
25
- should_record_messages: bool = False,
26
25
  exit_on_error: bool = False,
27
26
  exit_on_critical: bool = False,
28
27
  activate_wrn_interceptions: bool = True,
@@ -31,7 +30,6 @@ class loggers_t(dict[h.Hashable, logger_t]):
31
30
  ) -> None:
32
31
  """"""
33
32
  logger = logger_t(
34
- should_record_messages=should_record_messages,
35
33
  exit_on_error=exit_on_error,
36
34
  exit_on_critical=exit_on_critical,
37
35
  name_=name,
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.25"
7
+ __version__ = "2025.27"
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.25
3
+ Version: 2025.27
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=gqr9_xGceDfeDrDRv0O1e-8Rn6mXcEV_iFdCtiuTyAk,1680
2
+ logger_36/version.py,sha256=qAg2mrOjz-6X7HvNM4DsgwzItwuB5XOxJLIbal9yr6E,1680
3
3
  logger_36/api/chronos.py,sha256=o_UMZbeExjb01aNURmzIjOMAHhI9e90nyvJJYcJR6VQ,1739
4
4
  logger_36/api/logger.py,sha256=eLZ2yuH-sYeh4Z2KnAwTRJEbmkmgzBPMncdqXfFUTG8,1760
5
5
  logger_36/api/memory.py,sha256=U4mMEkx8WRHk9q2d3SCFGt2EJaBuflOXw2bGbAxOnSc,1828
@@ -8,9 +8,9 @@ logger_36/api/storage.py,sha256=S1fVzrMp-_zlhg27fRPddWCFQRyvbpFwSreALOeoNFI,1713
8
8
  logger_36/catalog/config/console_rich.py,sha256=t9p9-AkSgPiLAsm1evAdbz77g7JcVLePhUJ1FzNi3cY,2330
9
9
  logger_36/catalog/config/optional.py,sha256=8d8HdpE07gHfsdoL8mVAlRlh9AgLcb4z7I7h6ob7CfU,2174
10
10
  logger_36/catalog/handler/console.py,sha256=XIyO_8MrzaTlihDbFhIzRk47HjxMH4gV2Zqp0-1oMsU,2320
11
- logger_36/catalog/handler/console_rich.py,sha256=RXLu8AQxAmyec1bXUc99Mabp7BjZc-lKEfwrCzMPkZA,6662
11
+ logger_36/catalog/handler/console_rich.py,sha256=PSHsul03HNjQR8GmQVU3Z0DNNaudOYNmcTNOuldxSnQ,6667
12
12
  logger_36/catalog/handler/file.py,sha256=5GR_aACDEBXuZ-pUH9P0OCaXbCf-aLPmsz-XrGCAIgE,2434
13
- logger_36/catalog/handler/generic.py,sha256=kwr7x7GWLmWvT7niHGW7OqlMotvTQNuNEwQGfKh_nhU,7040
13
+ logger_36/catalog/handler/generic.py,sha256=HhBtM3JZBJjW2OLALnxdoWLsFs6J-AMzyFwwUs-woIA,7046
14
14
  logger_36/catalog/handler/memory.py,sha256=pJwKOlCm8Ej8ipDI00-FfX4qJjMPXJb-DucD1ukIQOU,4057
15
15
  logger_36/catalog/logger/chronos.py,sha256=MDAx_NRRcRZcQYDDjVCRcu87SDP-rPYjX0-10KNcMnk,2216
16
16
  logger_36/catalog/logger/gpu.py,sha256=Py5YY0nD_pqJzJsEKQYoOGHcPqyNVJ3J2noOS3hDL6g,2890
@@ -34,7 +34,7 @@ logger_36/constant/rule.py,sha256=ul-MqOdHBGBC5Nwn05EUnz2T__7VEs82qiH7Fzs5qCk,18
34
34
  logger_36/constant/system.py,sha256=pLlLXG5sepQlSUOo3TphaGrHg8xzJBp-GxpL2NPP47k,1904
35
35
  logger_36/extension/file.py,sha256=ClY8k805DnB6Vy0LEQIhlO0MavP91Y-CEjHjFepyROE,2034
36
36
  logger_36/extension/inspection.py,sha256=LoHXi4wsIgHKrq_7GYkVcfJ9rnBG16pLKMpAoHNwJiY,3922
37
- logger_36/extension/line.py,sha256=9BgxnY6wiyc44Ari5rkvqbvz9ao4sNs39u8k7sY6vFc,2611
37
+ logger_36/extension/line.py,sha256=CY--1urLqD5dCbAYOcOkAACP1jJXATxn4sWPbqqQkdY,2581
38
38
  logger_36/extension/sentinel.py,sha256=SQgkQiRcTIjCRvbxiOb6TEm59BC0FNMcjYoIShpcwLo,1718
39
39
  logger_36/instance/logger.py,sha256=X_U10RYU1h2Aa70D8hBnmFyJZtRILK16KN-GB4xkHMU,1782
40
40
  logger_36/instance/loggers.py,sha256=inBk4KKrQ-z3szaopQ29-qQwh1iSc842sWo5J6zJoiM,1725
@@ -43,11 +43,11 @@ logger_36/task/format/memory.py,sha256=xcWwbUnl1BxH7RVBHyhp1RlbT2n370PzoFLLLd3dt
43
43
  logger_36/task/format/message.py,sha256=Q9QkyUAU47Nj606zsvq0gNyso8Vk9G9OaqG9Em5FjKg,3575
44
44
  logger_36/task/measure/chronos.py,sha256=fZKK16LwlLzRRAP-gfF1uy6gFCL33gR7LZ4Xs_nXdVY,2612
45
45
  logger_36/task/measure/memory.py,sha256=kkPHEIUTUhkCOLrAt01eLJLnsnkl0nFPNhFZdIB_JAw,1991
46
- logger_36/type/handler.py,sha256=bDsCFYpevCJBV7Vc9jovttapjU-7GXI1_TDbmOf2kN4,6660
46
+ logger_36/type/handler.py,sha256=8ufQEjfIIk63rBTu0B-LF67x_UKDuFvnzC3g7CnfK18,6666
47
47
  logger_36/type/issue.py,sha256=M2KeQwzDG9yqgdtbyWk5Y-ier7c71TuAKlNCf5QCGzY,2770
48
- logger_36/type/logger.py,sha256=0OjqyMcBAyS0qUUeEzweALrs0m5rVqZF3e6R1b8B4RA,27358
49
- logger_36/type/loggers.py,sha256=7EX7Sg_RlduBjdfFlNZmUfNeDloH1xU30Rdkg_-rXh8,3172
50
- logger_36-2025.25.dist-info/METADATA,sha256=Uchfn7mGuqLow-qAR-TejGvwkXNns2N7XnpLbgHeGFE,5980
51
- logger_36-2025.25.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
52
- logger_36-2025.25.dist-info/top_level.txt,sha256=sM95BTMWmslEEgR_1pzwZsOeSp8C_QBiu8ImbFr0XLc,10
53
- logger_36-2025.25.dist-info/RECORD,,
48
+ logger_36/type/logger.py,sha256=0Cgq_SwI8ofiRxYS0duDWHGVYZAzmxfGuXj2KYHRIEE,27481
49
+ logger_36/type/loggers.py,sha256=tFcuso9KGLDHnFfCaEJTDukUyYnbZEZrffpm59SDYO0,3067
50
+ logger_36-2025.27.dist-info/METADATA,sha256=m-TedtBHSYi0asize26skN3F1qoifv22ioSnNIvNYw4,5980
51
+ logger_36-2025.27.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
52
+ logger_36-2025.27.dist-info/top_level.txt,sha256=sM95BTMWmslEEgR_1pzwZsOeSp8C_QBiu8ImbFr0XLc,10
53
+ logger_36-2025.27.dist-info/RECORD,,