logger-36 2023.13__py3-none-any.whl → 2025.3__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. logger_36/__init__.py +65 -41
  2. logger_36/api/logger.py +53 -0
  3. logger_36/api/storage.py +53 -0
  4. logger_36/catalog/config/console_rich.py +76 -0
  5. logger_36/catalog/handler/console.py +117 -0
  6. logger_36/catalog/handler/console_rich.py +235 -0
  7. logger_36/catalog/handler/file.py +128 -0
  8. logger_36/catalog/handler/generic.py +228 -0
  9. logger_36/catalog/logger/chronos.py +61 -0
  10. logger_36/catalog/logger/gpu.py +90 -0
  11. logger_36/catalog/logger/memory.py +129 -0
  12. logger_36/catalog/logger/system.py +84 -0
  13. logger_36/config/issue.py +56 -0
  14. logger_36/config/logger.py +103 -0
  15. logger_36/config/memory.py +54 -0
  16. logger_36/config/message.py +66 -0
  17. logger_36/config/system.py +70 -0
  18. logger_36/constant/error.py +70 -0
  19. logger_36/constant/generic.py +58 -0
  20. logger_36/constant/handler.py +58 -0
  21. logger_36/constant/issue.py +58 -0
  22. logger_36/constant/logger.py +67 -0
  23. logger_36/constant/memory.py +58 -0
  24. logger_36/constant/message.py +72 -0
  25. logger_36/constant/record.py +55 -0
  26. logger_36/constant/system.py +60 -0
  27. logger_36/content.py +55 -0
  28. logger_36/exception.py +105 -0
  29. logger_36/gpu.py +53 -0
  30. logger_36/handler.py +209 -0
  31. logger_36/instance/logger.py +55 -0
  32. logger_36/instance/loggers.py +56 -0
  33. logger_36/memory.py +60 -0
  34. logger_36/storage.py +53 -0
  35. logger_36/system.py +53 -0
  36. logger_36/task/format/memory.py +132 -0
  37. logger_36/task/format/message.py +111 -0
  38. logger_36/task/format/rule.py +74 -0
  39. logger_36/task/inspection.py +70 -48
  40. logger_36/task/measure/chronos.py +84 -0
  41. logger_36/task/measure/memory.py +72 -0
  42. logger_36/task/storage.py +164 -0
  43. logger_36/time.py +54 -0
  44. logger_36/type/handler.py +184 -0
  45. logger_36/type/issue.py +91 -0
  46. logger_36/type/logger.py +542 -0
  47. logger_36/type/loggers.py +78 -0
  48. logger_36/version.py +53 -32
  49. logger_36-2025.3.dist-info/METADATA +154 -0
  50. logger_36-2025.3.dist-info/RECORD +52 -0
  51. {logger_36-2023.13.dist-info → logger_36-2025.3.dist-info}/WHEEL +1 -1
  52. logger_36/config.py +0 -66
  53. logger_36/constant.py +0 -57
  54. logger_36/main.py +0 -185
  55. logger_36/measure/chronos.py +0 -55
  56. logger_36/measure/memory.py +0 -102
  57. logger_36/type/console.py +0 -122
  58. logger_36/type/extension.py +0 -122
  59. logger_36/type/file.py +0 -52
  60. logger_36/type/generic.py +0 -116
  61. logger_36-2023.13.dist-info/METADATA +0 -106
  62. logger_36-2023.13.dist-info/RECORD +0 -16
  63. {logger_36-2023.13.dist-info → logger_36-2025.3.dist-info}/top_level.txt +0 -0
logger_36/time.py ADDED
@@ -0,0 +1,54 @@
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
+ from logger_36.catalog.logger.chronos import LogElapsedTime
8
+ from logger_36.task.measure.chronos import ElapsedTime, TimeStamp
9
+
10
+ """
11
+ COPYRIGHT NOTICE
12
+
13
+ This software is governed by the CeCILL license under French law and
14
+ abiding by the rules of distribution of free software. You can use,
15
+ modify and/ or redistribute the software under the terms of the CeCILL
16
+ license as circulated by CEA, CNRS and INRIA at the following URL
17
+ "http://www.cecill.info".
18
+
19
+ As a counterpart to the access to the source code and rights to copy,
20
+ modify and redistribute granted by the license, users are provided only
21
+ with a limited warranty and the software's author, the holder of the
22
+ economic rights, and the successive licensors have only limited
23
+ liability.
24
+
25
+ In this respect, the user's attention is drawn to the risks associated
26
+ with loading, using, modifying and/or developing or reproducing the
27
+ software by the user in light of its specific status of free software,
28
+ that may mean that it is complicated to manipulate, and that also
29
+ therefore means that it is reserved for developers and experienced
30
+ professionals having in-depth computer knowledge. Users are therefore
31
+ encouraged to load and test the software's suitability as regards their
32
+ requirements in conditions enabling the security of their systems and/or
33
+ data to be ensured and, more generally, to use and operate it in the
34
+ same conditions as regards security.
35
+
36
+ The fact that you are presently reading this means that you have had
37
+ knowledge of the CeCILL license and that you accept its terms.
38
+
39
+ SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
40
+
41
+ This software is being developed by Eric Debreuve, a CNRS employee and
42
+ member of team Morpheme.
43
+ Team Morpheme is a joint team between Inria, CNRS, and UniCA.
44
+ It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
45
+ I3S, and Laboratory iBV.
46
+
47
+ CNRS: https://www.cnrs.fr/index.php/en
48
+ Inria: https://www.inria.fr/en/
49
+ UniCA: https://univ-cotedazur.eu/
50
+ Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
51
+ I3S: https://www.i3s.unice.fr/en/
52
+ iBV: http://ibv.unice.fr/
53
+ Team Morpheme: https://team.inria.fr/morpheme/
54
+ """
@@ -0,0 +1,184 @@
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 logging as lggg
9
+ import sys as sstm
10
+ import typing as h
11
+
12
+ from logger_36.config.message import (
13
+ LEVEL_CLOSING,
14
+ LEVEL_OPENING,
15
+ MESSAGE_MARKER,
16
+ WHERE_SEPARATOR,
17
+ )
18
+ from logger_36.constant.error import MEMORY_MEASURE_ERROR
19
+ from logger_36.constant.handler import HANDLER_CODES
20
+ from logger_36.constant.message import NEXT_LINE_PROLOGUE
21
+ from logger_36.task.format.message import MessageWithActualExpected
22
+ from logger_36.task.measure.chronos import TimeStamp
23
+ from logger_36.task.measure.memory import CanCheckUsage as CanCheckMemoryUsage
24
+
25
+ _MEMORY_MEASURE_ERROR = MEMORY_MEASURE_ERROR
26
+
27
+
28
+ @d.dataclass(slots=True, repr=False, eq=False)
29
+ class handler_extension_t:
30
+ name: str | None = None
31
+ should_store_memory_usage: bool = False
32
+ message_width: int = -1
33
+ MessageFromRecord: h.Callable[..., str] = d.field(init=False)
34
+
35
+ handler: d.InitVar[lggg.Handler | None] = None
36
+ level: d.InitVar[int] = lggg.NOTSET
37
+ formatter: d.InitVar[lggg.Formatter | None] = None
38
+
39
+ def __post_init__(
40
+ self, handler: lggg.Handler | None, level: int, formatter: lggg.Formatter | None
41
+ ) -> None:
42
+ """"""
43
+ global _MEMORY_MEASURE_ERROR
44
+
45
+ if self.name in HANDLER_CODES:
46
+ raise ValueError(
47
+ MessageWithActualExpected(
48
+ "Invalid handler name",
49
+ actual=self.name,
50
+ expected=f"a name not in {str(HANDLER_CODES)[1:-1]}",
51
+ )
52
+ )
53
+
54
+ if self.name is None:
55
+ self.name = TimeStamp()
56
+
57
+ if self.should_store_memory_usage and not CanCheckMemoryUsage():
58
+ self.should_store_memory_usage = False
59
+ if _MEMORY_MEASURE_ERROR is not None:
60
+ print(_MEMORY_MEASURE_ERROR, file=sstm.stderr)
61
+ _MEMORY_MEASURE_ERROR = None
62
+
63
+ handler.setLevel(level)
64
+
65
+ if 0 < self.message_width < 5:
66
+ self.message_width = 5
67
+ if formatter is None:
68
+ self.MessageFromRecord = self._MessageFromRecord
69
+ else:
70
+ handler.setFormatter(formatter)
71
+ self.MessageFromRecord = handler.formatter.format
72
+
73
+ def _MessageFromRecord(
74
+ self,
75
+ record: lggg.LogRecord,
76
+ /,
77
+ *,
78
+ PreProcessed: h.Callable[[str], str] | None = None,
79
+ ) -> str:
80
+ """
81
+ See logger_36.catalog.handler.README.txt.
82
+ """
83
+ message = record.msg
84
+
85
+ if PreProcessed is not None:
86
+ message = PreProcessed(message)
87
+ if (self.message_width <= 0) or (message.__len__() <= self.message_width):
88
+ if "\n" in message:
89
+ message = NEXT_LINE_PROLOGUE.join(message.splitlines())
90
+ else:
91
+ if "\n" in message:
92
+ lines = _WrappedLines(message.splitlines(), self.message_width)
93
+ else:
94
+ lines = _WrappedLines([message], self.message_width)
95
+ message = NEXT_LINE_PROLOGUE.join(lines)
96
+
97
+ if (where := getattr(record, "where", None)) is None:
98
+ where = ""
99
+ else:
100
+ where = f"{NEXT_LINE_PROLOGUE}{WHERE_SEPARATOR} {where}"
101
+
102
+ return (
103
+ f"{record.when_or_elapsed}"
104
+ f"{LEVEL_OPENING}{record.level_first_letter}{LEVEL_CLOSING} "
105
+ f"{MESSAGE_MARKER} {message}{where}"
106
+ )
107
+
108
+
109
+ def _WrappedLines(lines: list[str], message_width: int, /) -> list[str]:
110
+ """"""
111
+ output = []
112
+
113
+ for line in lines:
114
+ while line.__len__() > message_width:
115
+ if all(
116
+ _elm != " " for _elm in line[(message_width - 1) : (message_width + 1)]
117
+ ):
118
+ if line[message_width - 2] == " ":
119
+ piece, line = (
120
+ line[: (message_width - 2)].rstrip(),
121
+ line[(message_width - 1) :],
122
+ )
123
+ else:
124
+ piece, line = (
125
+ line[: (message_width - 1)] + "-",
126
+ line[(message_width - 1) :],
127
+ )
128
+ else:
129
+ piece, line = (
130
+ line[:message_width].rstrip(),
131
+ line[message_width:].lstrip(),
132
+ )
133
+ output.append(piece)
134
+
135
+ output.append(line)
136
+
137
+ return output
138
+
139
+
140
+ """
141
+ COPYRIGHT NOTICE
142
+
143
+ This software is governed by the CeCILL license under French law and
144
+ abiding by the rules of distribution of free software. You can use,
145
+ modify and/ or redistribute the software under the terms of the CeCILL
146
+ license as circulated by CEA, CNRS and INRIA at the following URL
147
+ "http://www.cecill.info".
148
+
149
+ As a counterpart to the access to the source code and rights to copy,
150
+ modify and redistribute granted by the license, users are provided only
151
+ with a limited warranty and the software's author, the holder of the
152
+ economic rights, and the successive licensors have only limited
153
+ liability.
154
+
155
+ In this respect, the user's attention is drawn to the risks associated
156
+ with loading, using, modifying and/or developing or reproducing the
157
+ software by the user in light of its specific status of free software,
158
+ that may mean that it is complicated to manipulate, and that also
159
+ therefore means that it is reserved for developers and experienced
160
+ professionals having in-depth computer knowledge. Users are therefore
161
+ encouraged to load and test the software's suitability as regards their
162
+ requirements in conditions enabling the security of their systems and/or
163
+ data to be ensured and, more generally, to use and operate it in the
164
+ same conditions as regards security.
165
+
166
+ The fact that you are presently reading this means that you have had
167
+ knowledge of the CeCILL license and that you accept its terms.
168
+
169
+ SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
170
+
171
+ This software is being developed by Eric Debreuve, a CNRS employee and
172
+ member of team Morpheme.
173
+ Team Morpheme is a joint team between Inria, CNRS, and UniCA.
174
+ It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
175
+ I3S, and Laboratory iBV.
176
+
177
+ CNRS: https://www.cnrs.fr/index.php/en
178
+ Inria: https://www.inria.fr/en/
179
+ UniCA: https://univ-cotedazur.eu/
180
+ Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
181
+ I3S: https://www.i3s.unice.fr/en/
182
+ iBV: http://ibv.unice.fr/
183
+ Team Morpheme: https://team.inria.fr/morpheme/
184
+ """
@@ -0,0 +1,91 @@
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 logging as lggg
8
+ import typing as h
9
+
10
+ from logger_36.config.issue import ISSUE_BASE_CONTEXT
11
+ from logger_36.constant.generic import NOT_PASSED
12
+ from logger_36.constant.issue import ISSUE_LEVEL_SEPARATOR
13
+ from logger_36.constant.message import expected_op_h
14
+ from logger_36.task.format.message import MessageWithActualExpected
15
+
16
+ issue_t = str
17
+
18
+
19
+ def NewIssue(
20
+ context: str,
21
+ separator: str,
22
+ message: str,
23
+ /,
24
+ *,
25
+ level: int = lggg.ERROR,
26
+ actual: h.Any = NOT_PASSED,
27
+ expected: h.Any | None = None,
28
+ expected_is_choices: bool = False,
29
+ expected_op: expected_op_h = "=",
30
+ with_final_dot: bool = True,
31
+ ) -> issue_t:
32
+ """"""
33
+ if context.__len__() == 0:
34
+ context = ISSUE_BASE_CONTEXT
35
+ message = MessageWithActualExpected(
36
+ message,
37
+ actual=actual,
38
+ expected=expected,
39
+ expected_is_choices=expected_is_choices,
40
+ expected_op=expected_op,
41
+ with_final_dot=with_final_dot,
42
+ )
43
+
44
+ return f"{level}{ISSUE_LEVEL_SEPARATOR}{context}{separator}{message}"
45
+
46
+
47
+ """
48
+ COPYRIGHT NOTICE
49
+
50
+ This software is governed by the CeCILL license under French law and
51
+ abiding by the rules of distribution of free software. You can use,
52
+ modify and/ or redistribute the software under the terms of the CeCILL
53
+ license as circulated by CEA, CNRS and INRIA at the following URL
54
+ "http://www.cecill.info".
55
+
56
+ As a counterpart to the access to the source code and rights to copy,
57
+ modify and redistribute granted by the license, users are provided only
58
+ with a limited warranty and the software's author, the holder of the
59
+ economic rights, and the successive licensors have only limited
60
+ liability.
61
+
62
+ In this respect, the user's attention is drawn to the risks associated
63
+ with loading, using, modifying and/or developing or reproducing the
64
+ software by the user in light of its specific status of free software,
65
+ that may mean that it is complicated to manipulate, and that also
66
+ therefore means that it is reserved for developers and experienced
67
+ professionals having in-depth computer knowledge. Users are therefore
68
+ encouraged to load and test the software's suitability as regards their
69
+ requirements in conditions enabling the security of their systems and/or
70
+ data to be ensured and, more generally, to use and operate it in the
71
+ same conditions as regards security.
72
+
73
+ The fact that you are presently reading this means that you have had
74
+ knowledge of the CeCILL license and that you accept its terms.
75
+
76
+ SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
77
+
78
+ This software is being developed by Eric Debreuve, a CNRS employee and
79
+ member of team Morpheme.
80
+ Team Morpheme is a joint team between Inria, CNRS, and UniCA.
81
+ It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
82
+ I3S, and Laboratory iBV.
83
+
84
+ CNRS: https://www.cnrs.fr/index.php/en
85
+ Inria: https://www.inria.fr/en/
86
+ UniCA: https://univ-cotedazur.eu/
87
+ Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
88
+ I3S: https://www.i3s.unice.fr/en/
89
+ iBV: http://ibv.unice.fr/
90
+ Team Morpheme: https://team.inria.fr/morpheme/
91
+ """