logger-36 2025.7__py3-none-any.whl → 2025.8__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/api/storage.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
- from logger_36.task.storage import html_reader_t # noqa
7
+ from logger_36.extension.html_ import html_content_t # noqa
8
8
 
9
9
  """
10
10
  COPYRIGHT NOTICE
@@ -74,6 +74,15 @@ class console_rich_handler_t(l.Handler):
74
74
 
75
75
  rich_kwargs: d.InitVar[dict[str, h.Any] | None] = None
76
76
 
77
+ @property
78
+ def past_logs_as_HTML(self) -> str | None:
79
+ """"""
80
+ console = self.console
81
+ if console.record:
82
+ return console.export_html()
83
+
84
+ return None
85
+
77
86
  def __post_init__(
78
87
  self,
79
88
  name: str | None,
@@ -0,0 +1,107 @@
1
+ """
2
+ Copyright CNRS/Inria/UniCA
3
+ Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
4
+ SEE COPYRIGHT NOTICE BELOW
5
+ """
6
+
7
+ import dataclasses as d
8
+ import re as r
9
+ from html.parser import HTMLParser as base_t
10
+
11
+ _BODY_END_PATTERN = r"</[bB][oO][dD][yY]>(.|\n)*$"
12
+
13
+
14
+ @d.dataclass(slots=True, repr=False, eq=False)
15
+ class html_content_t(base_t):
16
+ source: str = ""
17
+ inside_body: bool = d.field(init=False, default=False)
18
+ body_position_start: tuple[int, int] = d.field(init=False, default=(-1, -1))
19
+ body_position_end: tuple[int, int] = d.field(init=False, default=(-1, -1))
20
+ pieces: list[str] = d.field(init=False, default_factory=list)
21
+
22
+ @property
23
+ def body(self) -> str:
24
+ """"""
25
+ output = self.source.splitlines()
26
+ output = "\n".join(
27
+ output[self.body_position_start[0] : (self.body_position_end[0] + 1)]
28
+ )
29
+ output = output[self.body_position_start[1] :]
30
+ output = r.sub(_BODY_END_PATTERN, "", output, count=1)
31
+
32
+ return output.strip()
33
+
34
+ @property
35
+ def body_as_text(self) -> str:
36
+ """"""
37
+ return "".join(self.pieces).strip()
38
+
39
+ def __post_init__(self) -> None:
40
+ """"""
41
+ base_t.__init__(self)
42
+ self.source = self.source.strip()
43
+ self.feed(self.source)
44
+
45
+ def handle_starttag(self, tag: str, attrs: list[tuple[str, str | None]], /) -> None:
46
+ """"""
47
+ if tag == "body":
48
+ self.body_position_start = self.getpos()
49
+ self.inside_body = True
50
+
51
+ def handle_endtag(self, tag: str, /) -> None:
52
+ """"""
53
+ if tag == "body":
54
+ self.body_position_end = self.getpos()
55
+ self.inside_body = False
56
+
57
+ def handle_data(self, data: str, /) -> None:
58
+ """"""
59
+ if self.inside_body:
60
+ self.pieces.append(data)
61
+
62
+
63
+ """
64
+ COPYRIGHT NOTICE
65
+
66
+ This software is governed by the CeCILL license under French law and
67
+ abiding by the rules of distribution of free software. You can use,
68
+ modify and/ or redistribute the software under the terms of the CeCILL
69
+ license as circulated by CEA, CNRS and INRIA at the following URL
70
+ "http://www.cecill.info".
71
+
72
+ As a counterpart to the access to the source code and rights to copy,
73
+ modify and redistribute granted by the license, users are provided only
74
+ with a limited warranty and the software's author, the holder of the
75
+ economic rights, and the successive licensors have only limited
76
+ liability.
77
+
78
+ In this respect, the user's attention is drawn to the risks associated
79
+ with loading, using, modifying and/or developing or reproducing the
80
+ software by the user in light of its specific status of free software,
81
+ that may mean that it is complicated to manipulate, and that also
82
+ therefore means that it is reserved for developers and experienced
83
+ professionals having in-depth computer knowledge. Users are therefore
84
+ encouraged to load and test the software's suitability as regards their
85
+ requirements in conditions enabling the security of their systems and/or
86
+ data to be ensured and, more generally, to use and operate it in the
87
+ same conditions as regards security.
88
+
89
+ The fact that you are presently reading this means that you have had
90
+ knowledge of the CeCILL license and that you accept its terms.
91
+
92
+ SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
93
+
94
+ This software is being developed by Eric Debreuve, a CNRS employee and
95
+ member of team Morpheme.
96
+ Team Morpheme is a joint team between Inria, CNRS, and UniCA.
97
+ It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
98
+ I3S, and Laboratory iBV.
99
+
100
+ CNRS: https://www.cnrs.fr/index.php/en
101
+ Inria: https://www.inria.fr/en/
102
+ UniCA: https://univ-cotedazur.eu/
103
+ Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
104
+ I3S: https://www.i3s.unice.fr/en/
105
+ iBV: http://ibv.unice.fr/
106
+ Team Morpheme: https://team.inria.fr/morpheme/
107
+ """
logger_36/task/storage.py CHANGED
@@ -4,73 +4,12 @@ Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
4
4
  SEE COPYRIGHT NOTICE BELOW
5
5
  """
6
6
 
7
- import dataclasses as d
8
7
  import logging as l
9
- import re as r
10
- from html.parser import HTMLParser as html_parser_t
11
8
  from io import IOBase as io_base_t
12
9
  from pathlib import Path as path_t
13
10
 
14
- from logger_36.catalog.config.optional import RICH_IS_AVAILABLE
15
11
  from logger_36.instance.logger import L
16
12
 
17
- if RICH_IS_AVAILABLE:
18
- from rich.console import Console as console_t # noqa
19
- else:
20
- console_t = None
21
-
22
-
23
- _BODY_END_PATTERN = r"</[bB][oO][dD][yY]>(.|\n)*$"
24
-
25
-
26
- @d.dataclass(slots=True, repr=False, eq=False)
27
- class html_reader_t(html_parser_t):
28
- source: str = ""
29
- inside_body: bool = d.field(init=False, default=False)
30
- body_position_start: tuple[int, int] = d.field(init=False, default=(-1, -1))
31
- body_position_end: tuple[int, int] = d.field(init=False, default=(-1, -1))
32
- pieces: list[str] = d.field(init=False, default_factory=list)
33
-
34
- def __post_init__(self) -> None:
35
- """"""
36
- html_parser_t.__init__(self)
37
- self.source = self.source.strip()
38
- self.feed(self.source)
39
-
40
- def handle_starttag(self, tag: str, attrs: list[tuple[str, str | None]], /) -> None:
41
- """"""
42
- if tag == "body":
43
- self.body_position_start = self.getpos()
44
- self.inside_body = True
45
-
46
- def handle_endtag(self, tag: str, /) -> None:
47
- """"""
48
- if tag == "body":
49
- self.body_position_end = self.getpos()
50
- self.inside_body = False
51
-
52
- def handle_data(self, data: str, /) -> None:
53
- """"""
54
- if self.inside_body:
55
- self.pieces.append(data)
56
-
57
- @property
58
- def body(self) -> str:
59
- """"""
60
- output = self.source.splitlines()
61
- output = "\n".join(
62
- output[self.body_position_start[0] : (self.body_position_end[0] + 1)]
63
- )
64
- output = output[self.body_position_start[1] :]
65
- output = r.sub(_BODY_END_PATTERN, "", output, count=1)
66
-
67
- return output.strip()
68
-
69
- @property
70
- def body_as_text(self) -> str:
71
- """"""
72
- return "".join(self.pieces).strip()
73
-
74
13
 
75
14
  def SaveLOGasHTML(path: str | path_t | io_base_t | None = None) -> None:
76
15
  """
@@ -78,18 +17,15 @@ def SaveLOGasHTML(path: str | path_t | io_base_t | None = None) -> None:
78
17
  """
79
18
  cannot_save = "Cannot save logging record as HTML"
80
19
 
81
- if console_t is None:
82
- L.warning(f"{cannot_save}: The Rich console cannot be imported.")
83
- return
84
-
85
20
  if path is None:
86
21
  for handler in L.handlers:
87
22
  if isinstance(handler, l.FileHandler):
88
23
  path = path_t(handler.baseFilename).with_suffix(".htm")
89
24
  break
90
- if path is None:
25
+ else:
91
26
  L.warning(f"{cannot_save}: No file handler to build a filename from.")
92
27
  return
28
+
93
29
  if path.exists():
94
30
  L.warning(
95
31
  f'{cannot_save}: Automatically generated path "{path}" already exists.'
@@ -103,18 +39,15 @@ def SaveLOGasHTML(path: str | path_t | io_base_t | None = None) -> None:
103
39
  L.warning(f'{cannot_save}: File "{path}" already exists.')
104
40
  return
105
41
 
106
- for handler in L.handlers:
107
- console = getattr(handler, "console", None)
108
- if isinstance(console, console_t) and console.record:
109
- html = console.export_html()
110
- if actual_file:
111
- with open(path, "w") as accessor:
112
- accessor.write(html)
113
- else:
114
- path.write(html)
115
- break
42
+ html = L.past_logs_as_HTML
43
+ if html is None:
44
+ L.warning(f"{cannot_save}: No handler could provide an HTML output.")
116
45
  else:
117
- L.warning(f"{cannot_save}: No handler has a RICH console with recording ON.")
46
+ if actual_file:
47
+ with open(path, "w") as accessor:
48
+ accessor.write(html)
49
+ else:
50
+ path.write(html)
118
51
 
119
52
 
120
53
  """
logger_36/type/logger.py CHANGED
@@ -102,6 +102,18 @@ class logger_t(base_t):
102
102
  """"""
103
103
  return self.staged_issues.__len__() > 0
104
104
 
105
+ @property
106
+ def past_logs_as_HTML(self) -> str | None:
107
+ """
108
+ From the first handler found with the given functionality, if any.
109
+ """
110
+ for handler in self.handlers:
111
+ past_logs_as_HTML = getattr(handler, "past_logs_as_HTML", None)
112
+ if past_logs_as_HTML is not None:
113
+ return past_logs_as_HTML
114
+
115
+ return None
116
+
105
117
  @property
106
118
  def max_memory_usage(self) -> int:
107
119
  """"""
@@ -338,6 +350,7 @@ class logger_t(base_t):
338
350
  if state:
339
351
  assert not self.intercepts_logs
340
352
 
353
+ # Note: Alternative to self.manager is logging.root.manager.
341
354
  all_loggers = [l.getLogger()] + [
342
355
  l.getLogger(_nme)
343
356
  for _nme in self.manager.loggerDict
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.7"
7
+ __version__ = "2025.8"
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.7
3
+ Version: 2025.8
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
@@ -7,13 +7,13 @@ 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=QWIy4Jr-I6cIfY2uS0OZkwf54A1Oh3Rxgb14HI6W6bE,2205
10
+ logger_36/version.py,sha256=dIKiLoaPWfEeTZKKzEklIyLlE8cFbHUq2h72W5GmOiI,2205
11
11
  logger_36/api/logger.py,sha256=TE3ATbymeWX-wBKBFkVz2FxUyJnaqY7vzFwAONVsp2o,2233
12
- logger_36/api/storage.py,sha256=KT52AGR37nsMrhKTVfG8R-Dc7lmCXjWML18cOqqCXZY,2239
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=s2DBcDK9To-wVS228RsDDPmOPxlIbVnQbZINfIK2TP0,4150
16
- logger_36/catalog/handler/console_rich.py,sha256=pI0OE0c5I19-ycvOJjdG5vdtDXTZadNNRbKCJD-2oL4,8347
16
+ logger_36/catalog/handler/console_rich.py,sha256=uYCoxPBPypaioSibC68Vw9r1XoY8AB5pAq2-RV1a4wQ,8544
17
17
  logger_36/catalog/handler/file.py,sha256=2qbsI3UHxqEm9WiCMkAm20hA2qXth2wKnakazVbwrBs,4613
18
18
  logger_36/catalog/handler/generic.py,sha256=y-f6HY5xppoHYYnej0qOQT3BI0Gam_0W1_bIHCk5nn0,9212
19
19
  logger_36/catalog/logger/chronos.py,sha256=ocY13f98EfknU7wZCv0FS9Xb7pTNaWCPSusXFIEvEd4,2437
@@ -34,10 +34,11 @@ logger_36/constant/message.py,sha256=Ys_CAyhENlT8Z3rr-AxO4hjdl1jLsKzVSPQ8wqLOCPQ
34
34
  logger_36/constant/path.py,sha256=fKJn2vGj012BU5DFRetDFus_tKMty2q_WL0J2KrXdCo,2731
35
35
  logger_36/constant/record.py,sha256=9Q28lVH_s0og4v74delgwIPAJ9G28I5rBM-brXcoY80,2308
36
36
  logger_36/constant/system.py,sha256=G2mzBTxRXoJMxb53TnmBaceMJC_q3WonoCG7y6nC_R8,2430
37
+ logger_36/extension/html_.py,sha256=J9EX8-Rotq9i8bZ9U-dIpXv5gKLLnLmWqdDy4XayT1Q,3868
37
38
  logger_36/instance/logger.py,sha256=oTw5svRzKRJKvGrrZUtutJIOjp5UISft3fl0Ze7DOBE,2241
38
39
  logger_36/instance/loggers.py,sha256=RCWpC1NPAf6vXnFc9NqsSALv-x-FEzcH6k_OlxTxeQk,2251
39
40
  logger_36/task/inspection.py,sha256=KZzmQyREQ6VmBWCLyNIYIOOISW9C_fC9TWTSX90zGDk,5019
40
- logger_36/task/storage.py,sha256=2B4OU7RqpUe98-pY9fadfnW8aFwxtsLSRGKkBtGWn-k,5686
41
+ logger_36/task/storage.py,sha256=T96JZT5Tmrt_-Kqf_WKweTvJYPX6lmPZZkJzCqyVPcI,3502
41
42
  logger_36/task/format/memory.py,sha256=jpQS8tAdxy7GM_FzqEIJUU3m-6O9iX-jiyO7gx5YwR8,4266
42
43
  logger_36/task/format/message.py,sha256=T2V2gUlUQqSojyRrz4I4uAHwNe6eBEsuAe6V-LTyx0k,3867
43
44
  logger_36/task/format/rule.py,sha256=vkf-HivFb4VqV2GeOPVqMAp99krtziI-kXhox3UVnzw,2873
@@ -45,9 +46,9 @@ logger_36/task/measure/chronos.py,sha256=1kVhu6jZlNAtNWQQh8ZVuRwZIAC9gGz3_ul1tn0
45
46
  logger_36/task/measure/memory.py,sha256=OjU5EYFH8SnzlCQKAoiXvauUlwQYOrH34jFXTVYF0jE,2517
46
47
  logger_36/type/handler.py,sha256=-myl7uBMOzkwCs1u4ehuYlQa9F6909jmnL2v_eQN5ag,6819
47
48
  logger_36/type/issue.py,sha256=2rGsFqaQJCbeml9xN08mN_nK79L8qscaS_0ws36Y0bI,3214
48
- logger_36/type/logger.py,sha256=nGNWJ5xcyA79E45qcZ-gZ3ZuY7j1aDg5NXk7VwbQVFU,22287
49
+ logger_36/type/logger.py,sha256=J6J87-RkH0RwiROeDQBnoTxLO5eXz32-GKjtxqyRXwk,22743
49
50
  logger_36/type/loggers.py,sha256=znqxWBnfQxvkg3VUfbTUvt3S6Kq0DAzWWepxQDt9suI,2871
50
- logger_36-2025.7.dist-info/METADATA,sha256=E708bS17nu3wkJZ7YTNfvezYSBUbfwXgUCwiiXwOkf0,6505
51
- logger_36-2025.7.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
52
- logger_36-2025.7.dist-info/top_level.txt,sha256=sM95BTMWmslEEgR_1pzwZsOeSp8C_QBiu8ImbFr0XLc,10
53
- logger_36-2025.7.dist-info/RECORD,,
51
+ logger_36-2025.8.dist-info/METADATA,sha256=R6yfIOmsKd4dJgf9EwdP7Mv1TtSlLD04g5liwcKXPOU,6505
52
+ logger_36-2025.8.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
53
+ logger_36-2025.8.dist-info/top_level.txt,sha256=sM95BTMWmslEEgR_1pzwZsOeSp8C_QBiu8ImbFr0XLc,10
54
+ logger_36-2025.8.dist-info/RECORD,,