logger-36 2024.26__py3-none-any.whl → 2024.28__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.
@@ -12,23 +12,24 @@ from rich.style import Style as style_t
12
12
  """
13
13
  Colors: See https://rich.readthedocs.io/en/stable/appendix/colors.html.
14
14
  """
15
- DATE_TIME_COLOR = "dodger_blue2"
15
+ WHITE_COLOR = "grey85"
16
+ GRAY_COLOR = "grey58"
17
+
16
18
  LEVEL_COLOR: dict[int, str | style_t] = {
17
19
  lggg.DEBUG: "orchid",
18
- lggg.INFO: "white",
19
- lggg.WARNING: "yellow",
20
- lggg.ERROR: "orange1",
21
- lggg.CRITICAL: "red",
20
+ lggg.INFO: GRAY_COLOR,
21
+ lggg.WARNING: "yellow1",
22
+ lggg.ERROR: "dark_orange",
23
+ lggg.CRITICAL: "bright_red",
22
24
  }
23
- ACTUAL_COLOR = "indian_red"
24
- EXPECTED_COLOR = "green"
25
- ELAPSED_TIME_COLOR = "green"
25
+ ACTUAL_COLOR = LEVEL_COLOR[lggg.CRITICAL]
26
+ EXPECTED_COLOR = "green3"
27
+ DATE_TIME_COLOR = "sky_blue3"
28
+ ELAPSED_TIME_COLOR = DATE_TIME_COLOR
26
29
 
27
30
  ALTERNATIVE_BACKGROUND_FOR_LIGHT = style_t(bgcolor=color_t.from_rgb(230, 230, 230))
28
31
  ALTERNATIVE_BACKGROUND_FOR_DARK = style_t(bgcolor=color_t.from_rgb(25, 25, 25))
29
32
 
30
- GRAY_STYLE = style_t(color=color_t.from_rgb(150, 150, 150))
31
-
32
33
  """
33
34
  COPYRIGHT NOTICE
34
35
 
@@ -6,7 +6,7 @@ SEE COPYRIGHT NOTICE BELOW
6
6
 
7
7
  import dataclasses as d
8
8
  import logging as lggg
9
- import textwrap as text
9
+ import textwrap as txt_
10
10
  import typing as h
11
11
 
12
12
  from logger_36.constant.message import LINE_INDENT
@@ -65,9 +65,13 @@ class console_handler_t(lggg.Handler):
65
65
  logger_36.catalog.handler.generic.generic_handler_t.ShowMessage.
66
66
  """
67
67
  if indented:
68
- message = text.indent(message, LINE_INDENT)
68
+ message = txt_.indent(message, LINE_INDENT)
69
69
  print(message)
70
70
 
71
+ def DisplayRule(self, /, *, text: str | None = None, color: str = "white") -> None:
72
+ """"""
73
+ self.ShowMessage(RuleAsText(text))
74
+
71
75
 
72
76
  """
73
77
  COPYRIGHT NOTICE
@@ -6,7 +6,7 @@ SEE COPYRIGHT NOTICE BELOW
6
6
 
7
7
  import dataclasses as d
8
8
  import logging as lggg
9
- import textwrap as text
9
+ import textwrap as txt_
10
10
  import typing as h
11
11
 
12
12
  from logger_36.catalog.config.console_rich import (
@@ -16,8 +16,9 @@ from logger_36.catalog.config.console_rich import (
16
16
  DATE_TIME_COLOR,
17
17
  ELAPSED_TIME_COLOR,
18
18
  EXPECTED_COLOR,
19
- GRAY_STYLE,
19
+ GRAY_COLOR,
20
20
  LEVEL_COLOR,
21
+ WHITE_COLOR,
21
22
  )
22
23
  from logger_36.config.message import (
23
24
  ACTUAL_PATTERNS,
@@ -26,7 +27,7 @@ from logger_36.config.message import (
26
27
  LEVEL_CLOSING,
27
28
  WHERE_SEPARATOR,
28
29
  )
29
- from logger_36.constant.message import LINE_INDENT, TIME_LENGTH
30
+ from logger_36.constant.message import LINE_INDENT
30
31
  from logger_36.constant.record import SHOW_W_RULE_ATTR
31
32
  from logger_36.task.format.rule import Rule
32
33
  from logger_36.type.handler import handler_extension_t
@@ -161,9 +162,13 @@ class console_rich_handler_t(lggg.Handler):
161
162
  logger_36.catalog.handler.generic.generic_handler_t.ShowMessage.
162
163
  """
163
164
  if indented:
164
- message = text.indent(message, LINE_INDENT)
165
+ message = txt_.indent(message, LINE_INDENT)
165
166
  self.console.print(message, crop=False, overflow="ignore")
166
167
 
168
+ def DisplayRule(self, /, *, text: str | None = None, color: str = "white") -> None:
169
+ """"""
170
+ self.ShowMessage(Rule(text, color))
171
+
167
172
 
168
173
  def HighlightedVersion(
169
174
  _: console_t,
@@ -176,7 +181,7 @@ def HighlightedVersion(
176
181
  background_is_light: bool = True,
177
182
  ) -> renderable_t:
178
183
  """"""
179
- output = text_t(first_line)
184
+ output = text_t(first_line, WHITE_COLOR)
180
185
 
181
186
  # Used instead of _CONTEXT_LENGTH which might include \t, thus creating a
182
187
  # mismatch between character length and length when displayed in console.
@@ -186,13 +191,8 @@ def HighlightedVersion(
186
191
  WHERE_SEPARATOR, context_end, elapsed_time_separator
187
192
  )
188
193
 
189
- output.stylize(DATE_TIME_COLOR, end=TIME_LENGTH)
190
- output.stylize(
191
- LEVEL_COLOR[log_level],
192
- start=TIME_LENGTH,
193
- end=context_end + 1,
194
- )
195
- output.stylize(GRAY_STYLE, start=where_separator, end=elapsed_time_separator)
194
+ output.stylize(LEVEL_COLOR[log_level], end=context_end + 1)
195
+ output.stylize(GRAY_COLOR, start=where_separator, end=elapsed_time_separator)
196
196
  output.stylize(ELAPSED_TIME_COLOR, start=elapsed_time_separator)
197
197
 
198
198
  if next_lines is not None:
@@ -6,7 +6,7 @@ SEE COPYRIGHT NOTICE BELOW
6
6
 
7
7
  import dataclasses as d
8
8
  import logging as lggg
9
- import textwrap as text
9
+ import textwrap as txt_
10
10
  import typing as h
11
11
  from pathlib import Path as path_t
12
12
 
@@ -75,10 +75,14 @@ class file_handler_t(lggg.FileHandler):
75
75
  logger_36.catalog.handler.generic.generic_handler_t.ShowMessage.
76
76
  """
77
77
  if indented:
78
- message = text.indent(message, LINE_INDENT)
78
+ message = txt_.indent(message, LINE_INDENT)
79
79
  print(message, file=self.stream)
80
80
  self.stream.flush()
81
81
 
82
+ def DisplayRule(self, /, *, text: str | None = None, color: str = "white") -> None:
83
+ """"""
84
+ self.ShowMessage(RuleAsText(text))
85
+
82
86
 
83
87
  """
84
88
  COPYRIGHT NOTICE
@@ -23,6 +23,14 @@ from logger_36.task.format.rule import Rule, RuleAsText
23
23
  from logger_36.type.handler import handler_extension_t
24
24
 
25
25
 
26
+ class show_message_p(h.Protocol):
27
+ def __call__(self, message: str, /, *, indented: bool = False) -> None: ...
28
+
29
+
30
+ class display_rule_p(h.Protocol):
31
+ def __call__(self, /, *, text: str | None = None, color: str = "white") -> None: ...
32
+
33
+
26
34
  @d.dataclass(slots=True, repr=False, eq=False)
27
35
  class generic_handler_t(lggg.Handler):
28
36
  """
@@ -44,12 +52,13 @@ class generic_handler_t(lggg.Handler):
44
52
  it is indeed called at the end of the emit method.
45
53
  """
46
54
 
47
- ShowMessage: h.Callable[[str], None]
48
- console: console_t = None
49
- console_options: console_options_t = None
55
+ ShowMessage: show_message_p
56
+ console: console_t | None = None
57
+ console_options: console_options_t | None = None
50
58
  alternating_lines: int = 0
51
59
  background_is_light: bool = True
52
60
 
61
+ DisplayRule: display_rule_p = d.field(init=False)
53
62
  extension: handler_extension_t = d.field(init=False)
54
63
  FormattedLines: h.Callable[..., tuple[str, str | None]] = d.field(init=False)
55
64
 
@@ -101,6 +110,9 @@ class generic_handler_t(lggg.Handler):
101
110
  self.console_options = self.console.options.update(
102
111
  overflow="ignore", no_wrap=True
103
112
  )
113
+ self.DisplayRule = self._DisplayRule
114
+ else:
115
+ self.DisplayRule = self._DisplayRuleAsText
104
116
 
105
117
  self.FormattedLines = self.extension.FormattedLines
106
118
  if self.alternating_lines == 1:
@@ -161,6 +173,16 @@ class generic_handler_t(lggg.Handler):
161
173
 
162
174
  self.ShowMessage(message)
163
175
 
176
+ def _DisplayRuleAsText(
177
+ self, /, *, text: str | None = None, color: str = "white"
178
+ ) -> None:
179
+ """"""
180
+ self.ShowMessage(RuleAsText(text))
181
+
182
+ def _DisplayRule(self, /, *, text: str | None = None, color: str = "white") -> None:
183
+ """"""
184
+ self.ShowMessage(Rule(text, color))
185
+
164
186
 
165
187
  """
166
188
  COPYRIGHT NOTICE
logger_36/handler.py CHANGED
@@ -6,12 +6,11 @@ SEE COPYRIGHT NOTICE BELOW
6
6
 
7
7
  import logging as lggg
8
8
  import sys as sstm
9
- import typing as h
10
9
  from pathlib import Path as path_t
11
10
 
12
11
  from logger_36.catalog.handler.console import console_handler_t
13
12
  from logger_36.catalog.handler.file import file_handler_t
14
- from logger_36.catalog.handler.generic import generic_handler_t
13
+ from logger_36.catalog.handler.generic import generic_handler_t, show_message_p
15
14
  from logger_36.constant.error import MISSING_RICH_ERROR
16
15
  from logger_36.instance.logger import LOGGER
17
16
 
@@ -28,7 +27,7 @@ except ModuleNotFoundError:
28
27
 
29
28
 
30
29
  def AddGenericHandler(
31
- ShowMessage: h.Callable[[str], None],
30
+ ShowMessage: show_message_p,
32
31
  /,
33
32
  *,
34
33
  logger: lggg.Logger | None = None,
logger_36/type/logger.py CHANGED
@@ -32,7 +32,6 @@ from logger_36.task.format.memory import (
32
32
  FormattedUsageWithAutoUnit as FormattedMemoryUsage,
33
33
  )
34
34
  from logger_36.task.format.message import FormattedMessage
35
- from logger_36.task.format.rule import Rule
36
35
  from logger_36.task.measure.chronos import ElapsedTime
37
36
  from logger_36.task.measure.memory import CurrentUsage as CurrentMemoryUsage
38
37
  from logger_36.type.issue import NewIssue, issue_t
@@ -292,7 +291,10 @@ class logger_t(lggg.Logger):
292
291
 
293
292
  def DisplayRule(self, /, *, text: str | None = None, color: str = "white") -> None:
294
293
  """"""
295
- self.ShowMessage(Rule(text, color))
294
+ for handler in self.handlers:
295
+ DisplayRule = getattr(handler, "DisplayRule", None)
296
+ if DisplayRule is not None:
297
+ DisplayRule(text=text, color=color)
296
298
 
297
299
  def AddContextLevel(self, new_level: str, /) -> None:
298
300
  """"""
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__ = "2024.26"
7
+ __version__ = "2024.28"
8
8
 
9
9
  """
10
10
  COPYRIGHT NOTICE
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: logger-36
3
- Version: 2024.26
3
+ Version: 2024.28
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
@@ -2,19 +2,19 @@ logger_36/__init__.py,sha256=NtDTs3eMKaXTJeujmgj1um3cBVLti0tYuOsdtVk9o9Q,2269
2
2
  logger_36/content.py,sha256=jobWhMw249uLfi8d8RFpKQRyyMXD7YQg-DxPMqvj2xs,2348
3
3
  logger_36/exception.py,sha256=UsFcsAvd1L4aLj6h7T-DilDm6yO501HDYnGekibiMAU,3260
4
4
  logger_36/gpu.py,sha256=YYFk6aYQrBDJfxQaDm-ar16T6SlOSL6jJWTOgvpF4EU,2244
5
- logger_36/handler.py,sha256=9KUu02RpKGKBR358gqS5G1Zut5C6MyBgGzRsQYFBAtY,6721
5
+ logger_36/handler.py,sha256=SmE2QdHfpef9w4uSW1Kj0WHRnpfGa6G2up0tNK-nCrc,6709
6
6
  logger_36/memory.py,sha256=FTc3qCeMqnCNvHJ4Yds73noPENQx_U1MYB-R4LLUjVQ,2682
7
7
  logger_36/storage.py,sha256=TNfIXEfHcjixv75wocUyqwX62iDYsor4srRqC3FNzbc,2231
8
8
  logger_36/system.py,sha256=xzm6cMeTaCX9VX9ZRXUXgfqoT9oUtv3W2o_H2W0P-4Q,2243
9
9
  logger_36/time.py,sha256=_CtpQeUZdsUNGNfwzhoWUiUvawRgmonqwZPHouzWf5M,2308
10
- logger_36/version.py,sha256=aWIezgzKk1mCAVZR34AWQke-WZ-Cj33kdeWtA-fe7SU,2206
10
+ logger_36/version.py,sha256=6RZEHyBy6_xJn0rt_KwQysU6A37xbsTsQ4Nn3DpDz34,2206
11
11
  logger_36/api/logger.py,sha256=Wg2nzQeuRVZ4v-oy3Q2KdYsHSzF9v7a0Fk6BzLnbkYw,2225
12
12
  logger_36/api/storage.py,sha256=evKVqIsslA5X82LaZ2HQDxp7ltyNOn8Tr-3-Pic3eUo,2231
13
- logger_36/catalog/config/console_rich.py,sha256=QDkgSs3I7ZULvkd1q4J1hdvgyB857JJcJWxM9fdL51Y,2883
14
- logger_36/catalog/handler/console.py,sha256=gSNFCoKfTFg7ID8lJjlbZuVi-4C5j-eQX1q_vllXL9s,4183
15
- logger_36/catalog/handler/console_rich.py,sha256=gxh1Ud33SkfFnLs9lRD8mP18wDxJ_18q7YxUP0aVZao,8933
16
- logger_36/catalog/handler/file.py,sha256=YBl0-1jBn4W0fm_WYg9zMHwFU9DRaDKOBQsLGle_BSs,4635
17
- logger_36/catalog/handler/generic.py,sha256=wG6Z1-lHj_9o6cPurEVpPctFlec3BFeqx2mZU_krJt8,8379
13
+ logger_36/catalog/config/console_rich.py,sha256=TUEvXlWmoB0t5TIkI77s2G_gyM6yEf8JiuRoL1Gx4KA,2903
14
+ logger_36/catalog/handler/console.py,sha256=WN_6kEJIVCkfdG-h_I3Jntklsn2FIolpkRltoHQRetY,4330
15
+ logger_36/catalog/handler/console_rich.py,sha256=XIhxhFyWExZAfhhDMfH4qerV5idsXS78ZDt50Y2CmhI,8995
16
+ logger_36/catalog/handler/file.py,sha256=oY5ib9L8tppdeQOPnQUrAXy1dgoSvMreHZiE5RhQl9o,4782
17
+ logger_36/catalog/handler/generic.py,sha256=CqDl7ynTB2rGIJDa8vXFq64Kf4W7D85miV_p8mj0-8Q,9114
18
18
  logger_36/catalog/logger/chronos.py,sha256=eLqQw8N9vaGO23OCf5RrYDPbUeu7epUvDt9rH-dN7i0,2522
19
19
  logger_36/catalog/logger/gpu.py,sha256=vUFSP17e7U4nenMi5IMlDiP3cZvXe6nqEDpoqzTavdg,3490
20
20
  logger_36/catalog/logger/memory.py,sha256=Zel_UCnHqGAqf_YuKpvjt0OIOo9vwKYpFM9g_2bjir0,4790
@@ -44,9 +44,9 @@ logger_36/task/measure/chronos.py,sha256=PX7dESj0znstwAWW2tTQ5gcQuIlexzt1ZKcccyp
44
44
  logger_36/task/measure/memory.py,sha256=eVw5WOYLyn8o4O4mMArdX2MzsVuhhNDovjYEkk-MIaU,2504
45
45
  logger_36/type/handler.py,sha256=BXpevZhLq5V_IdUfi_LZA4czzlH2SGLpgvbqUBe5X10,8311
46
46
  logger_36/type/issue.py,sha256=Y7OCLCzVt6Yvkecwj8HXLdZjg33oMxexc9XkYHzUhh4,3202
47
- logger_36/type/logger.py,sha256=J08I5sw7Lr2bEDJo2aJc5b4LgTvU_5O4RCDoBnqsSEw,17432
47
+ logger_36/type/logger.py,sha256=iYDV5cEVE8Yb5DjnV74K8r5M16iK07Pf4u8mb8XszEo,17538
48
48
  logger_36/type/loggers.py,sha256=znqxWBnfQxvkg3VUfbTUvt3S6Kq0DAzWWepxQDt9suI,2871
49
- logger_36-2024.26.dist-info/METADATA,sha256=kL7MjQ1ERnbMmk2sz3BkSgMwTOMwn1v9WiQqjG3__GU,6276
50
- logger_36-2024.26.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
51
- logger_36-2024.26.dist-info/top_level.txt,sha256=sM95BTMWmslEEgR_1pzwZsOeSp8C_QBiu8ImbFr0XLc,10
52
- logger_36-2024.26.dist-info/RECORD,,
49
+ logger_36-2024.28.dist-info/METADATA,sha256=J9DLOQjTdAnHyPvtHMf8JXWuXvcNvdQFfToy99vK2ss,6276
50
+ logger_36-2024.28.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
51
+ logger_36-2024.28.dist-info/top_level.txt,sha256=sM95BTMWmslEEgR_1pzwZsOeSp8C_QBiu8ImbFr0XLc,10
52
+ logger_36-2024.28.dist-info/RECORD,,