logger-36 2025.9__py3-none-any.whl → 2025.10__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.
@@ -48,21 +48,15 @@ class console_rich_handler_t(l.Handler):
48
48
  """
49
49
  kind: See logger_36.constant.handler.handler_codes_h.
50
50
 
51
- alternating_lines:
52
- - Initial value:
53
- - 1: enabled for dark background
54
- - 2: enabled for light background
55
- - anything else: disabled
56
- - Runtime value: 0/1=do not/do highlight next time.
51
+ alternating_logs:
52
+ - 0: disabled
53
+ - 1: enabled for dark background
54
+ - 2: enabled for light background
57
55
  """
58
56
 
59
57
  kind: h.ClassVar[str] = "c"
60
58
 
61
- extension: handler_extension_t = d.field(init=False)
62
- console: console_t = d.field(init=False)
63
- MessageFromRecord: MessageFromRecordPreprocessed_p = d.field(init=False)
64
- alternating_lines: int = 0
65
- background_is_light: bool = True
59
+ alternating_logs: int = 0
66
60
 
67
61
  name: d.InitVar[str | None] = None
68
62
  level: d.InitVar[int] = l.NOTSET
@@ -74,6 +68,11 @@ class console_rich_handler_t(l.Handler):
74
68
  should_record: d.InitVar[bool] = False
75
69
  rich_kwargs: d.InitVar[dict[str, h.Any] | None] = None
76
70
 
71
+ extension: handler_extension_t = d.field(init=False)
72
+ console: console_t = d.field(init=False)
73
+ MessageFromRecord: MessageFromRecordPreprocessed_p = d.field(init=False)
74
+ log_parity: bool = d.field(init=False, default=False)
75
+
77
76
  @property
78
77
  def past_logs_as_HTML(self) -> str | None:
79
78
  """"""
@@ -130,14 +129,7 @@ class console_rich_handler_t(l.Handler):
130
129
  InstallTracebackHandler(**rich_traceback_kwargs)
131
130
 
132
131
  self.MessageFromRecord = self.extension.MessageFromRecord
133
- if self.alternating_lines == 1:
134
- self.alternating_lines = 0
135
- self.background_is_light = False
136
- elif self.alternating_lines == 2:
137
- self.alternating_lines = 0
138
- self.background_is_light = True
139
- else:
140
- self.alternating_lines = -1
132
+ assert self.alternating_logs in (0, 1, 2)
141
133
 
142
134
  def emit(self, record: l.LogRecord, /) -> None:
143
135
  """"""
@@ -145,17 +137,15 @@ class console_rich_handler_t(l.Handler):
145
137
  richer = Rule(record.msg, DATE_TIME_COLOR)
146
138
  else:
147
139
  message = self.MessageFromRecord(record, PreProcessed=EscapedVersion)
148
- should_highlight_back = self.alternating_lines == 1
149
- if self.alternating_lines >= 0:
150
- self.alternating_lines = (self.alternating_lines + 1) % 2
151
140
  richer = HighlightedVersion(
152
141
  self.console,
153
142
  message,
154
143
  record.levelno,
155
- should_highlight_back=should_highlight_back,
156
- background_is_light=self.background_is_light,
144
+ self.alternating_logs,
145
+ self.log_parity,
157
146
  )
158
147
  self.console.print(richer, crop=False, overflow="ignore")
148
+ self.log_parity = not self.log_parity
159
149
 
160
150
  def LogAsIs(self, message: str | renderable_t, /) -> None:
161
151
  """
@@ -173,10 +163,9 @@ def HighlightedVersion(
173
163
  _: console_t,
174
164
  message: str,
175
165
  log_level: int,
166
+ alternating_logs: int,
167
+ should_tint_background: bool,
176
168
  /,
177
- *,
178
- should_highlight_back: bool = False,
179
- background_is_light: bool = True,
180
169
  ) -> renderable_t:
181
170
  """"""
182
171
  output = text_t(message, WHITE_COLOR)
@@ -188,11 +177,11 @@ def HighlightedVersion(
188
177
  _ = output.highlight_words(ACTUAL_PATTERNS, style=ACTUAL_COLOR)
189
178
  _ = output.highlight_regex(EXPECTED_PATTERNS, style=EXPECTED_COLOR)
190
179
 
191
- if should_highlight_back:
192
- if background_is_light:
193
- style = ALTERNATIVE_BACKGROUND_FOR_LIGHT
194
- else:
180
+ if should_tint_background and (alternating_logs > 0):
181
+ if alternating_logs == 1:
195
182
  style = ALTERNATIVE_BACKGROUND_FOR_DARK
183
+ else:
184
+ style = ALTERNATIVE_BACKGROUND_FOR_LIGHT
196
185
  output.stylize(style)
197
186
 
198
187
  return output
@@ -39,12 +39,10 @@ class generic_handler_t(l.Handler):
39
39
  """
40
40
  kind: See logger_36.constant.handler.handler_codes_h.
41
41
 
42
- alternating_lines:
43
- - Initial value:
44
- - 1: enabled for dark background
45
- - 2: enabled for light background
46
- - anything else: disabled
47
- - Runtime value: 0/1=do not/do highlight next time.
42
+ alternating_logs:
43
+ - 0: disabled
44
+ - 1: enabled for dark background
45
+ - 2: enabled for light background
48
46
 
49
47
  LogAsIs:
50
48
  Log a message as is, i.e. without formatting. If this is a method, it should
@@ -63,12 +61,12 @@ class generic_handler_t(l.Handler):
63
61
  # "None -> h.Any" (twice below) since None | None is invalid.
64
62
  console: console_t | h.Any = None
65
63
  console_options: console_options_t | h.Any = None
66
- alternating_lines: int = 0
67
- background_is_light: bool = True
64
+ alternating_logs: int = 0
68
65
 
69
66
  DisplayRule: DisplayRule_p = d.field(init=False)
70
67
  extension: handler_extension_t = d.field(init=False)
71
68
  MessageFromRecord: MessageFromRecord_h = d.field(init=False)
69
+ log_parity: bool = d.field(init=False, default=False)
72
70
 
73
71
  name: d.InitVar[str | None] = None
74
72
  level: d.InitVar[int] = l.NOTSET
@@ -120,14 +118,7 @@ class generic_handler_t(l.Handler):
120
118
  self.DisplayRule = self._DisplayRuleAsText
121
119
 
122
120
  self.MessageFromRecord = self.extension.MessageFromRecord
123
- if self.alternating_lines == 1:
124
- self.alternating_lines = 0
125
- self.background_is_light = False
126
- elif self.alternating_lines == 2:
127
- self.alternating_lines = 0
128
- self.background_is_light = True
129
- else:
130
- self.alternating_lines = -1
121
+ assert self.alternating_logs in (0, 1, 2)
131
122
 
132
123
  def emit(self, record: l.LogRecord, /) -> None:
133
124
  """"""
@@ -141,15 +132,12 @@ class generic_handler_t(l.Handler):
141
132
  richer = Rule(record.msg, DATE_TIME_COLOR)
142
133
  else:
143
134
  message = self.MessageFromRecord(record, PreProcessed=EscapedForRich)
144
- should_highlight_back = self.alternating_lines == 1
145
- if self.alternating_lines >= 0:
146
- self.alternating_lines = (self.alternating_lines + 1) % 2
147
135
  richer = HighlightedVersion(
148
136
  self.console,
149
137
  message,
150
138
  record.levelno,
151
- should_highlight_back=should_highlight_back,
152
- background_is_light=self.background_is_light,
139
+ self.alternating_logs,
140
+ self.log_parity,
153
141
  )
154
142
  segments = self.console.render(richer, options=self.console_options)
155
143
 
@@ -176,6 +164,7 @@ class generic_handler_t(l.Handler):
176
164
  )
177
165
 
178
166
  self.LogAsIs(message)
167
+ self.log_parity = not self.log_parity
179
168
 
180
169
  def _DisplayRuleAsText(
181
170
  self, /, *, text: str | None = None, color: str = "white"
logger_36/handler.py CHANGED
@@ -33,7 +33,7 @@ def AddGenericHandler(
33
33
  message_width: int = -1,
34
34
  formatter: l.Formatter | None = None,
35
35
  supports_html: bool = False,
36
- alternating_lines: int = 2,
36
+ alternating_logs: int = 0,
37
37
  should_record: bool = False,
38
38
  should_hold_messages: bool = False,
39
39
  **kwargs,
@@ -46,7 +46,7 @@ def AddGenericHandler(
46
46
  message_width=message_width,
47
47
  formatter=formatter,
48
48
  supports_html=supports_html,
49
- alternating_lines=alternating_lines,
49
+ alternating_logs=alternating_logs,
50
50
  should_record=should_record,
51
51
  rich_kwargs=kwargs,
52
52
  LogAsIs=LogAsIs,
@@ -85,7 +85,7 @@ def AddRichConsoleHandler(
85
85
  should_store_memory_usage: bool = False,
86
86
  message_width: int = -1,
87
87
  formatter: l.Formatter | None = None,
88
- alternating_lines: int = 2,
88
+ alternating_logs: int = 0,
89
89
  should_hold_messages: bool = False,
90
90
  should_install_traceback: bool = False,
91
91
  should_record: bool = False,
@@ -101,7 +101,7 @@ def AddRichConsoleHandler(
101
101
  additional_s = {}
102
102
  else:
103
103
  additional_s = {
104
- "alternating_lines": alternating_lines,
104
+ "alternating_logs": alternating_logs,
105
105
  "should_install_traceback": should_install_traceback,
106
106
  "should_record": should_record,
107
107
  "rich_kwargs": kwargs,
logger_36/type/logger.py CHANGED
@@ -283,10 +283,10 @@ class logger_t(base_t):
283
283
  OverrideExceptionFormat()
284
284
  AddConsoleHandler(self)
285
285
 
286
- def MakeRich(self, *, alternating_lines: int = 2) -> None:
286
+ def MakeRich(self, *, alternating_logs: int = 0) -> None:
287
287
  """"""
288
288
  OverrideExceptionFormat()
289
- AddRichConsoleHandler(self, alternating_lines=alternating_lines)
289
+ AddRichConsoleHandler(self, alternating_logs=alternating_logs)
290
290
 
291
291
  def MakePermanent(self, path: str | path_t, /) -> None:
292
292
  """"""
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.9"
7
+ __version__ = "2025.10"
8
8
 
9
9
  """
10
10
  COPYRIGHT NOTICE
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: logger-36
3
- Version: 2025.9
3
+ Version: 2025.10
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,20 +2,20 @@ logger_36/__init__.py,sha256=3BtAgxFb14e9zzC5fXwqSQxstsd3BO0b_KVu3_wbLwg,2592
2
2
  logger_36/content.py,sha256=clHYYUKa8n4qef6PVlUV4mFHRRf6fnm9wEd2fu9oagA,2381
3
3
  logger_36/exception.py,sha256=9YWnS2LN_Mc0qYkohtbgEkzKe9ja2h_dBEd39ytGbRU,4605
4
4
  logger_36/gpu.py,sha256=BOumedCAPWvCo7J-KJ3XE-jr5S0KSmgcFv_S4QKRPO8,2252
5
- logger_36/handler.py,sha256=YOSkwLOO02Y69z-Hd7gtjng7s3VtgvlqnLMgv8jovI4,6309
5
+ logger_36/handler.py,sha256=fYc9L0RkMnlwKH_dSwOEeOV61D-L3zd-hxbPkzEvKbY,6303
6
6
  logger_36/memory.py,sha256=szJVk4UTXsbYv3B-W9LFttf1F3j86GXHsKgEUOsXKl4,2743
7
7
  logger_36/storage.py,sha256=sCxkHQH4xMaseweK1p2M1j0j2PxNPpy9MytPdg1sKiQ,2239
8
8
  logger_36/system.py,sha256=cgOMF_OneYeIJDMbIbIDx96EZss2uAdkk8QofOC7O1U,2251
9
9
  logger_36/time.py,sha256=Uw1jQtY1njsRuIPRAXX44v4nPOo84MSBu_WK_YCRzQs,2324
10
- logger_36/version.py,sha256=GMhKYpDckX_jLa0A1mt1reiX5XWPRZxrdkZSXbm_Km4,2205
10
+ logger_36/version.py,sha256=iy6wT5BEzB1vF_6nT0az2cXgwzIOb0RrSrqWYu1gq5g,2206
11
11
  logger_36/api/logger.py,sha256=TE3ATbymeWX-wBKBFkVz2FxUyJnaqY7vzFwAONVsp2o,2233
12
12
  logger_36/api/storage.py,sha256=v1iywLEItJCz18F_nJ20OnlpCpLdA-7EhlvqdLu42js,2243
13
13
  logger_36/catalog/config/console_rich.py,sha256=lAa5Ev5BhXvmQzfIt1FNihMNUQJFlXaIzNanAMdgtd0,2861
14
14
  logger_36/catalog/config/optional.py,sha256=HaN6mbx7gHBBppNvUw1ckhYTOrlYqb-b_r0mzPcHPjM,2398
15
15
  logger_36/catalog/handler/console.py,sha256=13ygxLmsywdGlr9hV9guw7FuRD-dxlZX20d1Mn-pWKs,4206
16
- logger_36/catalog/handler/console_rich.py,sha256=E9ysE_aREozf9qz-ooxzVMwT3aj13U6Mb8qtmomYwSI,8549
16
+ logger_36/catalog/handler/console_rich.py,sha256=RrNp8Uqf_MVw6o3Qcf7-4AfsZM_TjaTR2L_FKqD6LjI,8033
17
17
  logger_36/catalog/handler/file.py,sha256=ZbYLic0XcX3vw-col8hiuO-SQOSZh06tPYu5z3FdGDo,4620
18
- logger_36/catalog/handler/generic.py,sha256=sJwqUFKEcziVAtHrPLDemEdeB1VU-F2gXkbbLtsYJ-g,9217
18
+ logger_36/catalog/handler/generic.py,sha256=YYVdfG5nJHLIC-W9p8YhRREyFFSjJGHfSKJFd9EtLp0,8663
19
19
  logger_36/catalog/logger/chronos.py,sha256=ocY13f98EfknU7wZCv0FS9Xb7pTNaWCPSusXFIEvEd4,2437
20
20
  logger_36/catalog/logger/gpu.py,sha256=n_kbAQdRNk3Jdket6031_r2unOcz3dWplhCR-WFPjE0,3417
21
21
  logger_36/catalog/logger/memory.py,sha256=CWhr2J4BqArJxzH6tS-ZThr-rYPAQGtuLn0pP7Iryfg,4685
@@ -46,9 +46,9 @@ logger_36/task/measure/chronos.py,sha256=1kVhu6jZlNAtNWQQh8ZVuRwZIAC9gGz3_ul1tn0
46
46
  logger_36/task/measure/memory.py,sha256=OjU5EYFH8SnzlCQKAoiXvauUlwQYOrH34jFXTVYF0jE,2517
47
47
  logger_36/type/handler.py,sha256=5g5KdmKk6cdsUSV0JoFfjpAXdQIzSRcW81STyLqqWq8,6824
48
48
  logger_36/type/issue.py,sha256=2rGsFqaQJCbeml9xN08mN_nK79L8qscaS_0ws36Y0bI,3214
49
- logger_36/type/logger.py,sha256=4KkM_bIVRsjGO0ORloSibEb0MPtg88wSj5_wweRKjJU,22805
49
+ logger_36/type/logger.py,sha256=uqv5948_V8cUi_PBwtLGGNDcYe8NfaePQcZXvviCs9w,22802
50
50
  logger_36/type/loggers.py,sha256=znqxWBnfQxvkg3VUfbTUvt3S6Kq0DAzWWepxQDt9suI,2871
51
- logger_36-2025.9.dist-info/METADATA,sha256=AMDXKjSSMDRqWDLT0FeNYlV9bWGc2s1LXSDTD_h93sg,6505
52
- logger_36-2025.9.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
53
- logger_36-2025.9.dist-info/top_level.txt,sha256=sM95BTMWmslEEgR_1pzwZsOeSp8C_QBiu8ImbFr0XLc,10
54
- logger_36-2025.9.dist-info/RECORD,,
51
+ logger_36-2025.10.dist-info/METADATA,sha256=SD9qdZj7hf8PpN1Aezr9JYsUWaM7N2Grv-cBfT5BlHw,6506
52
+ logger_36-2025.10.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
53
+ logger_36-2025.10.dist-info/top_level.txt,sha256=sM95BTMWmslEEgR_1pzwZsOeSp8C_QBiu8ImbFr0XLc,10
54
+ logger_36-2025.10.dist-info/RECORD,,