logger-36 2025.17__py3-none-any.whl → 2025.19__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.
Files changed (55) hide show
  1. logger_36/__init__.py +1 -15
  2. logger_36/api/content.py +1 -16
  3. logger_36/api/gpu.py +1 -15
  4. logger_36/api/memory.py +1 -15
  5. logger_36/api/storage.py +1 -15
  6. logger_36/api/system.py +1 -15
  7. logger_36/api/time.py +1 -15
  8. logger_36/api/type.py +1 -15
  9. logger_36/catalog/config/console_rich.py +2 -16
  10. logger_36/catalog/config/optional.py +1 -15
  11. logger_36/catalog/handler/console.py +7 -24
  12. logger_36/catalog/handler/console_rich.py +14 -40
  13. logger_36/catalog/handler/file.py +5 -25
  14. logger_36/catalog/handler/generic.py +38 -81
  15. logger_36/catalog/logger/chronos.py +1 -15
  16. logger_36/catalog/logger/gpu.py +1 -15
  17. logger_36/catalog/logger/memory.py +1 -15
  18. logger_36/catalog/logger/system.py +1 -15
  19. logger_36/config/issue.py +1 -15
  20. logger_36/config/memory.py +1 -15
  21. logger_36/config/message.py +1 -15
  22. logger_36/config/system.py +1 -15
  23. logger_36/constant/error.py +1 -15
  24. logger_36/constant/generic.py +1 -15
  25. logger_36/constant/html.py +1 -15
  26. logger_36/constant/issue.py +1 -15
  27. logger_36/constant/logger.py +1 -15
  28. logger_36/constant/memory.py +1 -15
  29. logger_36/constant/message.py +1 -15
  30. logger_36/constant/path.py +2 -16
  31. logger_36/constant/record.py +1 -15
  32. logger_36/constant/{handler.py → rule.py} +5 -19
  33. logger_36/constant/system.py +1 -15
  34. logger_36/extension/html_.py +1 -15
  35. logger_36/extension/line.py +1 -15
  36. logger_36/instance/logger.py +3 -16
  37. logger_36/instance/loggers.py +1 -15
  38. logger_36/task/format/memory.py +1 -15
  39. logger_36/task/format/message.py +2 -75
  40. logger_36/task/inspection.py +1 -15
  41. logger_36/task/measure/chronos.py +1 -15
  42. logger_36/task/measure/memory.py +1 -15
  43. logger_36/task/storage.py +1 -15
  44. logger_36/type/handler.py +100 -79
  45. logger_36/type/issue.py +1 -15
  46. logger_36/type/logger.py +69 -85
  47. logger_36/type/loggers.py +2 -17
  48. logger_36/version.py +2 -16
  49. {logger_36-2025.17.dist-info → logger_36-2025.19.dist-info}/METADATA +2 -2
  50. logger_36-2025.19.dist-info/RECORD +52 -0
  51. logger_36/task/format/rule.py +0 -77
  52. logger_36/type/message.py +0 -90
  53. logger_36-2025.17.dist-info/RECORD +0 -54
  54. {logger_36-2025.17.dist-info → logger_36-2025.19.dist-info}/WHEEL +0 -0
  55. {logger_36-2025.17.dist-info → logger_36-2025.19.dist-info}/top_level.txt +0 -0
@@ -1,13 +1,13 @@
1
1
  """
2
- Copyright CNRS/Inria/UniCA
2
+ Copyright CNRS (https://www.cnrs.fr/index.php/en)
3
3
  Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
4
4
  SEE COPYRIGHT NOTICE BELOW
5
5
  """
6
6
 
7
- import typing as h
8
-
9
- handler_codes_h = h.Literal["g", "c", "f", "a"] # g=generic, c=console, f=file, a=all.
10
- HANDLER_KINDS: tuple[str, ...] = h.get_args(handler_codes_h)
7
+ RULE_CHARACTER = "-"
8
+ MIN_HALF_RULE_LENGTH = 4
9
+ DEFAULT_RULE_LENGTH = 50
10
+ DEFAULT_RULE = DEFAULT_RULE_LENGTH * RULE_CHARACTER
11
11
 
12
12
  """
13
13
  COPYRIGHT NOTICE
@@ -39,18 +39,4 @@ The fact that you are presently reading this means that you have had
39
39
  knowledge of the CeCILL license and that you accept its terms.
40
40
 
41
41
  SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
42
-
43
- This software is being developed by Eric Debreuve, a CNRS employee and
44
- member of team Morpheme.
45
- Team Morpheme is a joint team between Inria, CNRS, and UniCA.
46
- It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
47
- I3S, and Laboratory iBV.
48
-
49
- CNRS: https://www.cnrs.fr/index.php/en
50
- Inria: https://www.inria.fr/en/
51
- UniCA: https://univ-cotedazur.eu/
52
- Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
53
- I3S: https://www.i3s.unice.fr/en/
54
- iBV: http://ibv.unice.fr/
55
- Team Morpheme: https://team.inria.fr/morpheme/
56
42
  """
@@ -1,5 +1,5 @@
1
1
  """
2
- Copyright CNRS/Inria/UniCA
2
+ Copyright CNRS (https://www.cnrs.fr/index.php/en)
3
3
  Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
4
4
  SEE COPYRIGHT NOTICE BELOW
5
5
  """
@@ -43,18 +43,4 @@ The fact that you are presently reading this means that you have had
43
43
  knowledge of the CeCILL license and that you accept its terms.
44
44
 
45
45
  SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
46
-
47
- This software is being developed by Eric Debreuve, a CNRS employee and
48
- member of team Morpheme.
49
- Team Morpheme is a joint team between Inria, CNRS, and UniCA.
50
- It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
51
- I3S, and Laboratory iBV.
52
-
53
- CNRS: https://www.cnrs.fr/index.php/en
54
- Inria: https://www.inria.fr/en/
55
- UniCA: https://univ-cotedazur.eu/
56
- Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
57
- I3S: https://www.i3s.unice.fr/en/
58
- iBV: http://ibv.unice.fr/
59
- Team Morpheme: https://team.inria.fr/morpheme/
60
46
  """
@@ -1,5 +1,5 @@
1
1
  """
2
- Copyright CNRS/Inria/UniCA
2
+ Copyright CNRS (https://www.cnrs.fr/index.php/en)
3
3
  Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
4
4
  SEE COPYRIGHT NOTICE BELOW
5
5
  """
@@ -90,18 +90,4 @@ The fact that you are presently reading this means that you have had
90
90
  knowledge of the CeCILL license and that you accept its terms.
91
91
 
92
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
93
  """
@@ -1,5 +1,5 @@
1
1
  """
2
- Copyright CNRS/Inria/UniCA
2
+ Copyright CNRS (https://www.cnrs.fr/index.php/en)
3
3
  Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
4
4
  SEE COPYRIGHT NOTICE BELOW
5
5
  """
@@ -66,18 +66,4 @@ The fact that you are presently reading this means that you have had
66
66
  knowledge of the CeCILL license and that you accept its terms.
67
67
 
68
68
  SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
69
-
70
- This software is being developed by Eric Debreuve, a CNRS employee and
71
- member of team Morpheme.
72
- Team Morpheme is a joint team between Inria, CNRS, and UniCA.
73
- It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
74
- I3S, and Laboratory iBV.
75
-
76
- CNRS: https://www.cnrs.fr/index.php/en
77
- Inria: https://www.inria.fr/en/
78
- UniCA: https://univ-cotedazur.eu/
79
- Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
80
- I3S: https://www.i3s.unice.fr/en/
81
- iBV: http://ibv.unice.fr/
82
- Team Morpheme: https://team.inria.fr/morpheme/
83
69
  """
@@ -1,12 +1,13 @@
1
1
  """
2
- Copyright CNRS/Inria/UniCA
2
+ Copyright CNRS (https://www.cnrs.fr/index.php/en)
3
3
  Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
4
4
  SEE COPYRIGHT NOTICE BELOW
5
5
  """
6
6
 
7
+ from logger_36.constant.logger import LOGGER_NAME
7
8
  from logger_36.type.logger import logger_t
8
9
 
9
- L = logger_t()
10
+ L = logger_t(name_=LOGGER_NAME)
10
11
 
11
12
  """
12
13
  COPYRIGHT NOTICE
@@ -38,18 +39,4 @@ The fact that you are presently reading this means that you have had
38
39
  knowledge of the CeCILL license and that you accept its terms.
39
40
 
40
41
  SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
41
-
42
- This software is being developed by Eric Debreuve, a CNRS employee and
43
- member of team Morpheme.
44
- Team Morpheme is a joint team between Inria, CNRS, and UniCA.
45
- It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
46
- I3S, and Laboratory iBV.
47
-
48
- CNRS: https://www.cnrs.fr/index.php/en
49
- Inria: https://www.inria.fr/en/
50
- UniCA: https://univ-cotedazur.eu/
51
- Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
52
- I3S: https://www.i3s.unice.fr/en/
53
- iBV: http://ibv.unice.fr/
54
- Team Morpheme: https://team.inria.fr/morpheme/
55
42
  """
@@ -1,5 +1,5 @@
1
1
  """
2
- Copyright CNRS/Inria/UniCA
2
+ Copyright CNRS (https://www.cnrs.fr/index.php/en)
3
3
  Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
4
4
  SEE COPYRIGHT NOTICE BELOW
5
5
  """
@@ -39,18 +39,4 @@ The fact that you are presently reading this means that you have had
39
39
  knowledge of the CeCILL license and that you accept its terms.
40
40
 
41
41
  SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
42
-
43
- This software is being developed by Eric Debreuve, a CNRS employee and
44
- member of team Morpheme.
45
- Team Morpheme is a joint team between Inria, CNRS, and UniCA.
46
- It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
47
- I3S, and Laboratory iBV.
48
-
49
- CNRS: https://www.cnrs.fr/index.php/en
50
- Inria: https://www.inria.fr/en/
51
- UniCA: https://univ-cotedazur.eu/
52
- Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
53
- I3S: https://www.i3s.unice.fr/en/
54
- iBV: http://ibv.unice.fr/
55
- Team Morpheme: https://team.inria.fr/morpheme/
56
42
  """
@@ -1,5 +1,5 @@
1
1
  """
2
- Copyright CNRS/Inria/UniCA
2
+ Copyright CNRS (https://www.cnrs.fr/index.php/en)
3
3
  Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
4
4
  SEE COPYRIGHT NOTICE BELOW
5
5
  """
@@ -111,18 +111,4 @@ The fact that you are presently reading this means that you have had
111
111
  knowledge of the CeCILL license and that you accept its terms.
112
112
 
113
113
  SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
114
-
115
- This software is being developed by Eric Debreuve, a CNRS employee and
116
- member of team Morpheme.
117
- Team Morpheme is a joint team between Inria, CNRS, and UniCA.
118
- It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
119
- I3S, and Laboratory iBV.
120
-
121
- CNRS: https://www.cnrs.fr/index.php/en
122
- Inria: https://www.inria.fr/en/
123
- UniCA: https://univ-cotedazur.eu/
124
- Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
125
- I3S: https://www.i3s.unice.fr/en/
126
- iBV: http://ibv.unice.fr/
127
- Team Morpheme: https://team.inria.fr/morpheme/
128
114
  """
@@ -1,73 +1,14 @@
1
1
  """
2
- Copyright CNRS/Inria/UniCA
2
+ Copyright CNRS (https://www.cnrs.fr/index.php/en)
3
3
  Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
4
4
  SEE COPYRIGHT NOTICE BELOW
5
5
  """
6
6
 
7
7
  import difflib as diff
8
- import logging as l
9
8
  import typing as h
10
9
 
11
- from logger_36.config.message import (
12
- LEVEL_CLOSING,
13
- LEVEL_OPENING,
14
- MESSAGE_MARKER,
15
- WHERE_SEPARATOR,
16
- )
17
10
  from logger_36.constant.generic import NOT_PASSED
18
- from logger_36.constant.message import NEXT_LINE_PROLOGUE, expected_op_h
19
- from logger_36.constant.record import SHOW_W_RULE_ATTR
20
- from logger_36.extension.line import WrappedLines
21
- from logger_36.type.message import RuleWithText_h
22
-
23
-
24
- def MessageFromRecord(
25
- record: l.LogRecord,
26
- RuleWithText: RuleWithText_h,
27
- /,
28
- *,
29
- line_width: int = 0,
30
- color: str | None = None,
31
- PreProcessed: h.Callable[[str], str] | None = None,
32
- ) -> tuple[str, bool]:
33
- """
34
- See logger_36.catalog.handler.README.txt.
35
-
36
- The second returned value is is_not_a_rule.
37
- """
38
- message = record.msg
39
-
40
- if hasattr(record, SHOW_W_RULE_ATTR):
41
- return RuleWithText(message, color), False
42
-
43
- if PreProcessed is not None:
44
- message = PreProcessed(message)
45
- if (line_width <= 0) or (message.__len__() <= line_width):
46
- if "\n" in message:
47
- message = NEXT_LINE_PROLOGUE.join(message.splitlines())
48
- else:
49
- if "\n" in message:
50
- lines = WrappedLines(message.splitlines(), line_width)
51
- else:
52
- lines = WrappedLines([message], line_width)
53
- message = NEXT_LINE_PROLOGUE.join(lines)
54
-
55
- when_or_elapsed = getattr(record, "when_or_elapsed", None)
56
- if when_or_elapsed is None:
57
- return message, True
58
-
59
- level_first_letter = getattr(record, "level_first_letter", "")
60
-
61
- if (where := getattr(record, "where", None)) is None:
62
- where = ""
63
- else:
64
- where = f"{NEXT_LINE_PROLOGUE}{WHERE_SEPARATOR} {where}"
65
-
66
- return (
67
- f"{when_or_elapsed}"
68
- f"{LEVEL_OPENING}{level_first_letter}{LEVEL_CLOSING} "
69
- f"{MESSAGE_MARKER} {message}{where}"
70
- ), True
11
+ from logger_36.constant.message import expected_op_h
71
12
 
72
13
 
73
14
  def MessageWithActualExpected(
@@ -161,18 +102,4 @@ The fact that you are presently reading this means that you have had
161
102
  knowledge of the CeCILL license and that you accept its terms.
162
103
 
163
104
  SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
164
-
165
- This software is being developed by Eric Debreuve, a CNRS employee and
166
- member of team Morpheme.
167
- Team Morpheme is a joint team between Inria, CNRS, and UniCA.
168
- It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
169
- I3S, and Laboratory iBV.
170
-
171
- CNRS: https://www.cnrs.fr/index.php/en
172
- Inria: https://www.inria.fr/en/
173
- UniCA: https://univ-cotedazur.eu/
174
- Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
175
- I3S: https://www.i3s.unice.fr/en/
176
- iBV: http://ibv.unice.fr/
177
- Team Morpheme: https://team.inria.fr/morpheme/
178
105
  """
@@ -1,5 +1,5 @@
1
1
  """
2
- Copyright CNRS/Inria/UniCA
2
+ Copyright CNRS (https://www.cnrs.fr/index.php/en)
3
3
  Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
4
4
  SEE COPYRIGHT NOTICE BELOW
5
5
  """
@@ -132,18 +132,4 @@ The fact that you are presently reading this means that you have had
132
132
  knowledge of the CeCILL license and that you accept its terms.
133
133
 
134
134
  SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
135
-
136
- This software is being developed by Eric Debreuve, a CNRS employee and
137
- member of team Morpheme.
138
- Team Morpheme is a joint team between Inria, CNRS, and UniCA.
139
- It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
140
- I3S, and Laboratory iBV.
141
-
142
- CNRS: https://www.cnrs.fr/index.php/en
143
- Inria: https://www.inria.fr/en/
144
- UniCA: https://univ-cotedazur.eu/
145
- Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
146
- I3S: https://www.i3s.unice.fr/en/
147
- iBV: http://ibv.unice.fr/
148
- Team Morpheme: https://team.inria.fr/morpheme/
149
135
  """
@@ -1,5 +1,5 @@
1
1
  """
2
- Copyright CNRS/Inria/UniCA
2
+ Copyright CNRS (https://www.cnrs.fr/index.php/en)
3
3
  Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
4
4
  SEE COPYRIGHT NOTICE BELOW
5
5
  """
@@ -65,18 +65,4 @@ The fact that you are presently reading this means that you have had
65
65
  knowledge of the CeCILL license and that you accept its terms.
66
66
 
67
67
  SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
68
-
69
- This software is being developed by Eric Debreuve, a CNRS employee and
70
- member of team Morpheme.
71
- Team Morpheme is a joint team between Inria, CNRS, and UniCA.
72
- It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
73
- I3S, and Laboratory iBV.
74
-
75
- CNRS: https://www.cnrs.fr/index.php/en
76
- Inria: https://www.inria.fr/en/
77
- UniCA: https://univ-cotedazur.eu/
78
- Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
79
- I3S: https://www.i3s.unice.fr/en/
80
- iBV: http://ibv.unice.fr/
81
- Team Morpheme: https://team.inria.fr/morpheme/
82
68
  """
@@ -1,5 +1,5 @@
1
1
  """
2
- Copyright CNRS/Inria/UniCA
2
+ Copyright CNRS (https://www.cnrs.fr/index.php/en)
3
3
  Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
4
4
  SEE COPYRIGHT NOTICE BELOW
5
5
  """
@@ -55,18 +55,4 @@ The fact that you are presently reading this means that you have had
55
55
  knowledge of the CeCILL license and that you accept its terms.
56
56
 
57
57
  SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
58
-
59
- This software is being developed by Eric Debreuve, a CNRS employee and
60
- member of team Morpheme.
61
- Team Morpheme is a joint team between Inria, CNRS, and UniCA.
62
- It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
63
- I3S, and Laboratory iBV.
64
-
65
- CNRS: https://www.cnrs.fr/index.php/en
66
- Inria: https://www.inria.fr/en/
67
- UniCA: https://univ-cotedazur.eu/
68
- Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
69
- I3S: https://www.i3s.unice.fr/en/
70
- iBV: http://ibv.unice.fr/
71
- Team Morpheme: https://team.inria.fr/morpheme/
72
58
  """
logger_36/task/storage.py CHANGED
@@ -1,5 +1,5 @@
1
1
  """
2
- Copyright CNRS/Inria/UniCA
2
+ Copyright CNRS (https://www.cnrs.fr/index.php/en)
3
3
  Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
4
4
  SEE COPYRIGHT NOTICE BELOW
5
5
  """
@@ -101,18 +101,4 @@ The fact that you are presently reading this means that you have had
101
101
  knowledge of the CeCILL license and that you accept its terms.
102
102
 
103
103
  SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
104
-
105
- This software is being developed by Eric Debreuve, a CNRS employee and
106
- member of team Morpheme.
107
- Team Morpheme is a joint team between Inria, CNRS, and UniCA.
108
- It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
109
- I3S, and Laboratory iBV.
110
-
111
- CNRS: https://www.cnrs.fr/index.php/en
112
- Inria: https://www.inria.fr/en/
113
- UniCA: https://univ-cotedazur.eu/
114
- Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
115
- I3S: https://www.i3s.unice.fr/en/
116
- iBV: http://ibv.unice.fr/
117
- Team Morpheme: https://team.inria.fr/morpheme/
118
104
  """
logger_36/type/handler.py CHANGED
@@ -1,50 +1,49 @@
1
1
  """
2
- Copyright CNRS/Inria/UniCA
2
+ Copyright CNRS (https://www.cnrs.fr/index.php/en)
3
3
  Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
4
4
  SEE COPYRIGHT NOTICE BELOW
5
5
  """
6
6
 
7
7
  import logging as l
8
- import sys as s
9
8
  import typing as h
10
9
  from pathlib import Path as path_t
11
10
 
12
- from logger_36.config.message import FALLBACK_MESSAGE_WIDTH
13
- from logger_36.constant.handler import HANDLER_KINDS
14
- from logger_36.task.format.message import MessageFromRecord, MessageWithActualExpected
15
- from logger_36.task.format.rule import RuleAsText
16
- from logger_36.task.measure.chronos import TimeStamp
17
- from logger_36.type.message import MessageFromRecord_h, RuleWithText_h
18
-
19
-
20
- class _base_t:
21
- kind: h.ClassVar[str] = "" # See logger_36.constant.handler.handler_codes_h.
22
-
23
- def __init__(self, name: str | None, message_width: int) -> None:
11
+ from logger_36.config.message import (
12
+ FALLBACK_MESSAGE_WIDTH,
13
+ LEVEL_CLOSING,
14
+ LEVEL_OPENING,
15
+ MESSAGE_MARKER,
16
+ WHERE_SEPARATOR,
17
+ )
18
+ from logger_36.constant.message import NEXT_LINE_PROLOGUE
19
+ from logger_36.constant.record import SHOW_W_RULE_ATTR
20
+ from logger_36.constant.rule import (
21
+ DEFAULT_RULE,
22
+ DEFAULT_RULE_LENGTH,
23
+ MIN_HALF_RULE_LENGTH,
24
+ RULE_CHARACTER,
25
+ )
26
+ from logger_36.extension.line import WrappedLines
27
+
28
+
29
+ class extension_t:
30
+ def __init__(
31
+ self,
32
+ name: str | None,
33
+ message_width: int,
34
+ PreProcessedMessage: h.Callable[[str], str] | None,
35
+ ) -> None:
24
36
  """"""
25
- if name is None:
26
- name = f"{type(self).__name__}:{id(self)}"
27
-
28
37
  self.name = name
29
38
  self.message_width = message_width
30
- #
31
- self.MessageFromRecord: MessageFromRecord_h | None = None
39
+ self.PreProcessedMessage = PreProcessedMessage
32
40
 
33
41
  self.__post_init__()
34
42
 
35
43
  def __post_init__(self) -> None:
36
44
  """"""
37
- if self.name in HANDLER_KINDS:
38
- raise ValueError(
39
- MessageWithActualExpected(
40
- "Invalid handler name",
41
- actual=self.name,
42
- expected=f"a name not in {str(HANDLER_KINDS)[1:-1]}",
43
- )
44
- )
45
-
46
45
  if self.name is None:
47
- self.name = TimeStamp()
46
+ self.name = f"{type(self).__name__}:{hex(id(self))[2:]}"
48
47
 
49
48
  if 0 < self.message_width < FALLBACK_MESSAGE_WIDTH:
50
49
  self.message_width = FALLBACK_MESSAGE_WIDTH
@@ -56,40 +55,97 @@ class _base_t:
56
55
  """
57
56
  raise NotImplementedError
58
57
 
59
- def LogAsIs(self, message: str, /) -> None:
58
+ def MessageFromRecord(
59
+ self, record: l.LogRecord, /, *, rule_color: str | None = None
60
+ ) -> tuple[str, bool]:
61
+ """
62
+ The second returned value is is_not_a_rule.
63
+ """
64
+ message = record.msg # See logger_36.catalog.handler.README.txt.
65
+ if self.PreProcessedMessage is not None:
66
+ message = self.PreProcessedMessage(message)
67
+
68
+ if hasattr(record, SHOW_W_RULE_ATTR):
69
+ return self.Rule(message, color=rule_color), False
70
+
71
+ if (self.message_width <= 0) or (message.__len__() <= self.message_width):
72
+ if "\n" in message:
73
+ message = NEXT_LINE_PROLOGUE.join(message.splitlines())
74
+ else:
75
+ if "\n" in message:
76
+ lines = WrappedLines(message.splitlines(), self.message_width)
77
+ else:
78
+ lines = WrappedLines([message], self.message_width)
79
+ message = NEXT_LINE_PROLOGUE.join(lines)
80
+
81
+ when_or_elapsed = getattr(record, "when_or_elapsed", None)
82
+ if when_or_elapsed is None:
83
+ return message, True
84
+
85
+ level_first_letter = getattr(record, "level_first_letter", "")
86
+
87
+ if (where := getattr(record, "where", None)) is None:
88
+ where = ""
89
+ else:
90
+ where = f"{NEXT_LINE_PROLOGUE}{WHERE_SEPARATOR} {where}"
91
+
92
+ return (
93
+ f"{when_or_elapsed}"
94
+ f"{LEVEL_OPENING}{level_first_letter}{LEVEL_CLOSING} "
95
+ f"{MESSAGE_MARKER} {message}{where}"
96
+ ), True
97
+
98
+ def Rule(self, text: str | None, /, *, color: str = "black") -> str | h.Any:
60
99
  """
61
- See documentation of
62
- logger_36.catalog.handler.generic.generic_handler_t.LogAsIs.
100
+ Return type hint h.Any: For Rich, for example.
63
101
  """
64
- s.__stdout__.write(message + "\n")
102
+ if text is None:
103
+ if self.message_width > 0:
104
+ return self.message_width * RULE_CHARACTER
105
+ return DEFAULT_RULE
106
+
107
+ if self.message_width > 0:
108
+ target_width = self.message_width
109
+ else:
110
+ target_width = DEFAULT_RULE_LENGTH
111
+ half_rule_length = max(
112
+ (target_width - text.__len__() - 2) // 2, MIN_HALF_RULE_LENGTH
113
+ )
114
+ half_rule = half_rule_length * RULE_CHARACTER
115
+
116
+ return f"{half_rule} {text} {half_rule}"
117
+
118
+ def EmitAsIs(self, message: str, /) -> None:
119
+ """"""
120
+ raise NotImplementedError
65
121
 
66
- def DisplayRule(self, /, *, text: str | None = None, color: str = "black") -> None:
122
+ def EmitRule(self, /, *, text: str | None = None, color: str = "black") -> None:
67
123
  """"""
68
- self.LogAsIs(RuleAsText(text, None))
124
+ self.EmitAsIs(self.Rule(text, color=color))
69
125
 
70
126
 
71
- class handler_t(l.Handler, _base_t):
127
+ class handler_t(l.Handler, extension_t):
72
128
  def __init__(
73
129
  self,
74
130
  name: str | None,
75
131
  message_width: int,
132
+ PreProcessedMessage: h.Callable[[str], str] | None,
76
133
  level: int,
77
- formatter: l.Formatter | None,
78
134
  *_,
79
135
  ) -> None:
80
136
  """"""
81
137
  l.Handler.__init__(self)
82
- _base_t.__init__(self, name, message_width)
83
- __post_init__(self, level, formatter)
138
+ extension_t.__init__(self, name, message_width, PreProcessedMessage)
139
+ __post_init__(self, level)
84
140
 
85
141
 
86
- class file_handler_t(l.FileHandler, _base_t):
142
+ class file_handler_t(l.FileHandler, extension_t):
87
143
  def __init__(
88
144
  self,
89
145
  name: str | None,
90
146
  message_width: int,
147
+ PreProcessedMessage: h.Callable[[str], str] | None,
91
148
  level: int,
92
- formatter: l.Formatter | None,
93
149
  path: str | path_t | None,
94
150
  *_,
95
151
  ) -> None:
@@ -102,38 +158,17 @@ class file_handler_t(l.FileHandler, _base_t):
102
158
  raise ValueError(f"File or folder already exists: {path}.")
103
159
 
104
160
  l.FileHandler.__init__(self, path)
105
- _base_t.__init__(self, name, message_width)
106
- __post_init__(self, level, formatter)
161
+ extension_t.__init__(self, name, message_width, PreProcessedMessage)
162
+ __post_init__(self, level)
107
163
 
108
164
 
109
165
  any_handler_t = handler_t | file_handler_t
110
166
 
111
167
 
112
- def __post_init__(
113
- handler: any_handler_t, level: int, formatter: l.Formatter | None
114
- ) -> None:
168
+ def __post_init__(handler: any_handler_t, level: int) -> None:
115
169
  """"""
116
170
  handler.setLevel(level)
117
171
 
118
- if formatter is None:
119
- handler.MessageFromRecord = MessageFromRecord
120
- else:
121
- handler.setFormatter(formatter)
122
- _MessageFromRecordRaw = handler.formatter.format
123
-
124
- def _MessageFromRecord(
125
- record: l.LogRecord,
126
- _: RuleWithText_h,
127
- /,
128
- *,
129
- line_width: int = 0,
130
- PreProcessed: h.Callable[[str], str] | None = None,
131
- ) -> tuple[str, bool]:
132
- #
133
- return _MessageFromRecordRaw(record), False
134
-
135
- handler.MessageFromRecord = _MessageFromRecord
136
-
137
172
 
138
173
  """
139
174
  COPYRIGHT NOTICE
@@ -165,18 +200,4 @@ The fact that you are presently reading this means that you have had
165
200
  knowledge of the CeCILL license and that you accept its terms.
166
201
 
167
202
  SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
168
-
169
- This software is being developed by Eric Debreuve, a CNRS employee and
170
- member of team Morpheme.
171
- Team Morpheme is a joint team between Inria, CNRS, and UniCA.
172
- It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
173
- I3S, and Laboratory iBV.
174
-
175
- CNRS: https://www.cnrs.fr/index.php/en
176
- Inria: https://www.inria.fr/en/
177
- UniCA: https://univ-cotedazur.eu/
178
- Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
179
- I3S: https://www.i3s.unice.fr/en/
180
- iBV: http://ibv.unice.fr/
181
- Team Morpheme: https://team.inria.fr/morpheme/
182
203
  """