logger-36 2024.1__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 (67) hide show
  1. logger_36/__init__.py +64 -42
  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 +127 -46
  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-2024.1.dist-info → logger_36-2025.3.dist-info}/WHEEL +1 -1
  52. logger_36/catalog/gpu.py +0 -56
  53. logger_36/catalog/memory.py +0 -109
  54. logger_36/catalog/system.py +0 -84
  55. logger_36/config.py +0 -48
  56. logger_36/constant.py +0 -52
  57. logger_36/instance.py +0 -34
  58. logger_36/main.py +0 -96
  59. logger_36/measure/chronos.py +0 -55
  60. logger_36/measure/memory.py +0 -50
  61. logger_36/type/console.py +0 -122
  62. logger_36/type/extension.py +0 -122
  63. logger_36/type/file.py +0 -52
  64. logger_36/type/generic.py +0 -115
  65. logger_36-2024.1.dist-info/METADATA +0 -106
  66. logger_36-2024.1.dist-info/RECORD +0 -21
  67. {logger_36-2024.1.dist-info → logger_36-2025.3.dist-info}/top_level.txt +0 -0
logger_36/__init__.py CHANGED
@@ -1,44 +1,66 @@
1
- # Copyright CNRS/Inria/UCA
2
- # Contributor(s): Eric Debreuve (since 2023)
3
- #
4
- # eric.debreuve@cnrs.fr
5
- #
6
- # This software is governed by the CeCILL license under French law and
7
- # abiding by the rules of distribution of free software. You can use,
8
- # modify and/ or redistribute the software under the terms of the CeCILL
9
- # license as circulated by CEA, CNRS and INRIA at the following URL
10
- # "http://www.cecill.info".
11
- #
12
- # As a counterpart to the access to the source code and rights to copy,
13
- # modify and redistribute granted by the license, users are provided only
14
- # with a limited warranty and the software's author, the holder of the
15
- # economic rights, and the successive licensors have only limited
16
- # liability.
17
- #
18
- # In this respect, the user's attention is drawn to the risks associated
19
- # with loading, using, modifying and/or developing or reproducing the
20
- # software by the user in light of its specific status of free software,
21
- # that may mean that it is complicated to manipulate, and that also
22
- # therefore means that it is reserved for developers and experienced
23
- # professionals having in-depth computer knowledge. Users are therefore
24
- # encouraged to load and test the software's suitability as regards their
25
- # requirements in conditions enabling the security of their systems and/or
26
- # data to be ensured and, more generally, to use and operate it in the
27
- # same conditions as regards security.
28
- #
29
- # The fact that you are presently reading this means that you have had
30
- # knowledge of the CeCILL license and that you accept its terms.
31
-
32
- import logging as lggg
33
-
34
- from logger_36.instance import LOGGER
35
- from logger_36.main import (
36
- AddFileHandler,
37
- AddGenericHandler,
38
- SetExitOnError,
39
- SetLOGLevel,
40
- )
41
- from logger_36.type.console import console_handler_t
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
+ try:
8
+ from beartype.claw import beartype_this_package # noqa
9
+ except ModuleNotFoundError:
10
+ pass
11
+ else:
12
+ import site
13
+ from pathlib import Path as path_t
14
+ paths = site.getsitepackages() + [site.getusersitepackages()]
15
+ folder = path_t(__file__).parent
16
+ if folder not in paths:
17
+ beartype_this_package()
18
+
19
+ from logger_36.instance.logger import LOGGER
42
20
  from logger_36.version import __version__
43
21
 
44
- LOGGER.addHandler(console_handler_t(level=lggg.INFO))
22
+ """
23
+ COPYRIGHT NOTICE
24
+
25
+ This software is governed by the CeCILL license under French law and
26
+ abiding by the rules of distribution of free software. You can use,
27
+ modify and/ or redistribute the software under the terms of the CeCILL
28
+ license as circulated by CEA, CNRS and INRIA at the following URL
29
+ "http://www.cecill.info".
30
+
31
+ As a counterpart to the access to the source code and rights to copy,
32
+ modify and redistribute granted by the license, users are provided only
33
+ with a limited warranty and the software's author, the holder of the
34
+ economic rights, and the successive licensors have only limited
35
+ liability.
36
+
37
+ In this respect, the user's attention is drawn to the risks associated
38
+ with loading, using, modifying and/or developing or reproducing the
39
+ software by the user in light of its specific status of free software,
40
+ that may mean that it is complicated to manipulate, and that also
41
+ therefore means that it is reserved for developers and experienced
42
+ professionals having in-depth computer knowledge. Users are therefore
43
+ encouraged to load and test the software's suitability as regards their
44
+ requirements in conditions enabling the security of their systems and/or
45
+ data to be ensured and, more generally, to use and operate it in the
46
+ same conditions as regards security.
47
+
48
+ The fact that you are presently reading this means that you have had
49
+ knowledge of the CeCILL license and that you accept its terms.
50
+
51
+ SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
52
+
53
+ This software is being developed by Eric Debreuve, a CNRS employee and
54
+ member of team Morpheme.
55
+ Team Morpheme is a joint team between Inria, CNRS, and UniCA.
56
+ It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
57
+ I3S, and Laboratory iBV.
58
+
59
+ CNRS: https://www.cnrs.fr/index.php/en
60
+ Inria: https://www.inria.fr/en/
61
+ UniCA: https://univ-cotedazur.eu/
62
+ Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
63
+ I3S: https://www.i3s.unice.fr/en/
64
+ iBV: http://ibv.unice.fr/
65
+ Team Morpheme: https://team.inria.fr/morpheme/
66
+ """
@@ -0,0 +1,53 @@
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.type.logger import logger_t
8
+
9
+ """
10
+ COPYRIGHT NOTICE
11
+
12
+ This software is governed by the CeCILL license under French law and
13
+ abiding by the rules of distribution of free software. You can use,
14
+ modify and/ or redistribute the software under the terms of the CeCILL
15
+ license as circulated by CEA, CNRS and INRIA at the following URL
16
+ "http://www.cecill.info".
17
+
18
+ As a counterpart to the access to the source code and rights to copy,
19
+ modify and redistribute granted by the license, users are provided only
20
+ with a limited warranty and the software's author, the holder of the
21
+ economic rights, and the successive licensors have only limited
22
+ liability.
23
+
24
+ In this respect, the user's attention is drawn to the risks associated
25
+ with loading, using, modifying and/or developing or reproducing the
26
+ software by the user in light of its specific status of free software,
27
+ that may mean that it is complicated to manipulate, and that also
28
+ therefore means that it is reserved for developers and experienced
29
+ professionals having in-depth computer knowledge. Users are therefore
30
+ encouraged to load and test the software's suitability as regards their
31
+ requirements in conditions enabling the security of their systems and/or
32
+ data to be ensured and, more generally, to use and operate it in the
33
+ same conditions as regards security.
34
+
35
+ The fact that you are presently reading this means that you have had
36
+ knowledge of the CeCILL license and that you accept its terms.
37
+
38
+ SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
39
+
40
+ This software is being developed by Eric Debreuve, a CNRS employee and
41
+ member of team Morpheme.
42
+ Team Morpheme is a joint team between Inria, CNRS, and UniCA.
43
+ It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
44
+ I3S, and Laboratory iBV.
45
+
46
+ CNRS: https://www.cnrs.fr/index.php/en
47
+ Inria: https://www.inria.fr/en/
48
+ UniCA: https://univ-cotedazur.eu/
49
+ Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
50
+ I3S: https://www.i3s.unice.fr/en/
51
+ iBV: http://ibv.unice.fr/
52
+ Team Morpheme: https://team.inria.fr/morpheme/
53
+ """
@@ -0,0 +1,53 @@
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.task.storage import html_reader_t
8
+
9
+ """
10
+ COPYRIGHT NOTICE
11
+
12
+ This software is governed by the CeCILL license under French law and
13
+ abiding by the rules of distribution of free software. You can use,
14
+ modify and/ or redistribute the software under the terms of the CeCILL
15
+ license as circulated by CEA, CNRS and INRIA at the following URL
16
+ "http://www.cecill.info".
17
+
18
+ As a counterpart to the access to the source code and rights to copy,
19
+ modify and redistribute granted by the license, users are provided only
20
+ with a limited warranty and the software's author, the holder of the
21
+ economic rights, and the successive licensors have only limited
22
+ liability.
23
+
24
+ In this respect, the user's attention is drawn to the risks associated
25
+ with loading, using, modifying and/or developing or reproducing the
26
+ software by the user in light of its specific status of free software,
27
+ that may mean that it is complicated to manipulate, and that also
28
+ therefore means that it is reserved for developers and experienced
29
+ professionals having in-depth computer knowledge. Users are therefore
30
+ encouraged to load and test the software's suitability as regards their
31
+ requirements in conditions enabling the security of their systems and/or
32
+ data to be ensured and, more generally, to use and operate it in the
33
+ same conditions as regards security.
34
+
35
+ The fact that you are presently reading this means that you have had
36
+ knowledge of the CeCILL license and that you accept its terms.
37
+
38
+ SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
39
+
40
+ This software is being developed by Eric Debreuve, a CNRS employee and
41
+ member of team Morpheme.
42
+ Team Morpheme is a joint team between Inria, CNRS, and UniCA.
43
+ It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
44
+ I3S, and Laboratory iBV.
45
+
46
+ CNRS: https://www.cnrs.fr/index.php/en
47
+ Inria: https://www.inria.fr/en/
48
+ UniCA: https://univ-cotedazur.eu/
49
+ Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
50
+ I3S: https://www.i3s.unice.fr/en/
51
+ iBV: http://ibv.unice.fr/
52
+ Team Morpheme: https://team.inria.fr/morpheme/
53
+ """
@@ -0,0 +1,76 @@
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
+
9
+ from rich.color import Color as color_t
10
+ from rich.style import Style as style_t
11
+
12
+ """
13
+ Colors: See https://rich.readthedocs.io/en/stable/appendix/colors.html.
14
+ """
15
+ WHITE_COLOR = "grey85"
16
+ GRAY_COLOR = "grey58"
17
+
18
+ LEVEL_COLOR: dict[int, str | style_t] = {
19
+ lggg.DEBUG: "orchid",
20
+ lggg.INFO: GRAY_COLOR,
21
+ lggg.WARNING: "yellow1",
22
+ lggg.ERROR: "dark_orange",
23
+ lggg.CRITICAL: "bright_red",
24
+ }
25
+ ACTUAL_COLOR = LEVEL_COLOR[lggg.CRITICAL]
26
+ EXPECTED_COLOR = "green3"
27
+ DATE_TIME_COLOR = "sky_blue3"
28
+
29
+ ALTERNATIVE_BACKGROUND_FOR_LIGHT = style_t(bgcolor=color_t.from_rgb(230, 230, 230))
30
+ ALTERNATIVE_BACKGROUND_FOR_DARK = style_t(bgcolor=color_t.from_rgb(25, 25, 25))
31
+
32
+ """
33
+ COPYRIGHT NOTICE
34
+
35
+ This software is governed by the CeCILL license under French law and
36
+ abiding by the rules of distribution of free software. You can use,
37
+ modify and/ or redistribute the software under the terms of the CeCILL
38
+ license as circulated by CEA, CNRS and INRIA at the following URL
39
+ "http://www.cecill.info".
40
+
41
+ As a counterpart to the access to the source code and rights to copy,
42
+ modify and redistribute granted by the license, users are provided only
43
+ with a limited warranty and the software's author, the holder of the
44
+ economic rights, and the successive licensors have only limited
45
+ liability.
46
+
47
+ In this respect, the user's attention is drawn to the risks associated
48
+ with loading, using, modifying and/or developing or reproducing the
49
+ software by the user in light of its specific status of free software,
50
+ that may mean that it is complicated to manipulate, and that also
51
+ therefore means that it is reserved for developers and experienced
52
+ professionals having in-depth computer knowledge. Users are therefore
53
+ encouraged to load and test the software's suitability as regards their
54
+ requirements in conditions enabling the security of their systems and/or
55
+ data to be ensured and, more generally, to use and operate it in the
56
+ same conditions as regards security.
57
+
58
+ The fact that you are presently reading this means that you have had
59
+ knowledge of the CeCILL license and that you accept its terms.
60
+
61
+ SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
62
+
63
+ This software is being developed by Eric Debreuve, a CNRS employee and
64
+ member of team Morpheme.
65
+ Team Morpheme is a joint team between Inria, CNRS, and UniCA.
66
+ It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
67
+ I3S, and Laboratory iBV.
68
+
69
+ CNRS: https://www.cnrs.fr/index.php/en
70
+ Inria: https://www.inria.fr/en/
71
+ UniCA: https://univ-cotedazur.eu/
72
+ Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
73
+ I3S: https://www.i3s.unice.fr/en/
74
+ iBV: http://ibv.unice.fr/
75
+ Team Morpheme: https://team.inria.fr/morpheme/
76
+ """
@@ -0,0 +1,117 @@
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 textwrap as txt_
10
+ import typing as h
11
+
12
+ from logger_36.constant.message import LINE_INDENT
13
+ from logger_36.constant.record import SHOW_W_RULE_ATTR
14
+ from logger_36.task.format.rule import RuleAsText
15
+ from logger_36.type.handler import handler_extension_t
16
+
17
+
18
+ @d.dataclass(slots=True, repr=False, eq=False)
19
+ class console_handler_t(lggg.Handler):
20
+ extension: handler_extension_t = d.field(init=False)
21
+ MessageFromRecord: h.Callable[..., tuple[str, str | None]] = d.field(init=False)
22
+
23
+ name: d.InitVar[str | None] = None
24
+ level: d.InitVar[int] = lggg.NOTSET
25
+ should_store_memory_usage: d.InitVar[bool] = False
26
+ message_width: d.InitVar[int] = -1
27
+ formatter: d.InitVar[lggg.Formatter | None] = None
28
+
29
+ def __post_init__(
30
+ self,
31
+ name: str | None,
32
+ level: int,
33
+ should_store_memory_usage: bool,
34
+ message_width: int,
35
+ formatter: lggg.Formatter | None,
36
+ ) -> None:
37
+ """"""
38
+ lggg.Handler.__init__(self)
39
+
40
+ self.extension = handler_extension_t(
41
+ name=name,
42
+ should_store_memory_usage=should_store_memory_usage,
43
+ handler=self,
44
+ level=level,
45
+ message_width=message_width,
46
+ formatter=formatter,
47
+ )
48
+
49
+ self.MessageFromRecord = self.extension.MessageFromRecord
50
+
51
+ def emit(self, record: lggg.LogRecord, /) -> None:
52
+ """"""
53
+ if hasattr(record, SHOW_W_RULE_ATTR):
54
+ message = RuleAsText(record.msg)
55
+ else:
56
+ message = self.MessageFromRecord(record)
57
+ print(message)
58
+
59
+ def ShowMessage(self, message: str, /, *, indented: bool = False) -> None:
60
+ """
61
+ See documentation of
62
+ logger_36.catalog.handler.generic.generic_handler_t.ShowMessage.
63
+ """
64
+ if indented:
65
+ message = txt_.indent(message, LINE_INDENT)
66
+ print(message)
67
+
68
+ def DisplayRule(self, /, *, text: str | None = None, color: str = "white") -> None:
69
+ """"""
70
+ self.ShowMessage(RuleAsText(text))
71
+
72
+
73
+ """
74
+ COPYRIGHT NOTICE
75
+
76
+ This software is governed by the CeCILL license under French law and
77
+ abiding by the rules of distribution of free software. You can use,
78
+ modify and/ or redistribute the software under the terms of the CeCILL
79
+ license as circulated by CEA, CNRS and INRIA at the following URL
80
+ "http://www.cecill.info".
81
+
82
+ As a counterpart to the access to the source code and rights to copy,
83
+ modify and redistribute granted by the license, users are provided only
84
+ with a limited warranty and the software's author, the holder of the
85
+ economic rights, and the successive licensors have only limited
86
+ liability.
87
+
88
+ In this respect, the user's attention is drawn to the risks associated
89
+ with loading, using, modifying and/or developing or reproducing the
90
+ software by the user in light of its specific status of free software,
91
+ that may mean that it is complicated to manipulate, and that also
92
+ therefore means that it is reserved for developers and experienced
93
+ professionals having in-depth computer knowledge. Users are therefore
94
+ encouraged to load and test the software's suitability as regards their
95
+ requirements in conditions enabling the security of their systems and/or
96
+ data to be ensured and, more generally, to use and operate it in the
97
+ same conditions as regards security.
98
+
99
+ The fact that you are presently reading this means that you have had
100
+ knowledge of the CeCILL license and that you accept its terms.
101
+
102
+ SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
103
+
104
+ This software is being developed by Eric Debreuve, a CNRS employee and
105
+ member of team Morpheme.
106
+ Team Morpheme is a joint team between Inria, CNRS, and UniCA.
107
+ It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
108
+ I3S, and Laboratory iBV.
109
+
110
+ CNRS: https://www.cnrs.fr/index.php/en
111
+ Inria: https://www.inria.fr/en/
112
+ UniCA: https://univ-cotedazur.eu/
113
+ Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
114
+ I3S: https://www.i3s.unice.fr/en/
115
+ iBV: http://ibv.unice.fr/
116
+ Team Morpheme: https://team.inria.fr/morpheme/
117
+ """
@@ -0,0 +1,235 @@
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 textwrap as txt_
10
+ import typing as h
11
+
12
+ from logger_36.catalog.config.console_rich import (
13
+ ACTUAL_COLOR,
14
+ ALTERNATIVE_BACKGROUND_FOR_DARK,
15
+ ALTERNATIVE_BACKGROUND_FOR_LIGHT,
16
+ DATE_TIME_COLOR,
17
+ EXPECTED_COLOR,
18
+ GRAY_COLOR,
19
+ LEVEL_COLOR,
20
+ WHITE_COLOR,
21
+ )
22
+ from logger_36.config.message import ACTUAL_PATTERNS, EXPECTED_PATTERNS, WHERE_SEPARATOR
23
+ from logger_36.constant.message import CONTEXT_LENGTH, LINE_INDENT
24
+ from logger_36.constant.record import SHOW_W_RULE_ATTR
25
+ from logger_36.task.format.rule import Rule, rule_t
26
+ from logger_36.type.handler import handler_extension_t
27
+ from rich.console import Console as console_t
28
+ from rich.console import RenderableType as renderable_t
29
+ from rich.markup import escape as EscapedVersion
30
+ from rich.text import Text as text_t
31
+ from rich.traceback import install as InstallTracebackHandler
32
+
33
+ _COMMON_TRACEBACK_ARGUMENTS = ("theme", "width")
34
+ _EXCLUSIVE_TRACEBACK_ARGUMENTS = (
35
+ "extra_lines",
36
+ "indent_guides",
37
+ "locals_hide_dunder",
38
+ "locals_hide_sunder",
39
+ "locals_max_length",
40
+ "locals_max_string",
41
+ "max_frames" "show_locals",
42
+ "suppress",
43
+ "word_wrap",
44
+ )
45
+
46
+
47
+ @d.dataclass(slots=True, repr=False, eq=False)
48
+ class console_rich_handler_t(lggg.Handler):
49
+ """
50
+ alternating_lines:
51
+ - Initial value:
52
+ - 1: enabled for dark background
53
+ - 2: enabled for light background
54
+ - anything else: disabled
55
+ - Runtime value: 0/1=do not/do highlight next time.
56
+ """
57
+
58
+ extension: handler_extension_t = d.field(init=False)
59
+ console: console_t = d.field(init=False)
60
+ MessageFromRecord: h.Callable[..., str] = d.field(init=False)
61
+ alternating_lines: int = 0
62
+ background_is_light: bool = True
63
+
64
+ name: d.InitVar[str | None] = None
65
+ level: d.InitVar[int] = lggg.NOTSET
66
+ should_store_memory_usage: d.InitVar[bool] = False
67
+ message_width: d.InitVar[int] = -1
68
+ formatter: d.InitVar[lggg.Formatter | None] = None
69
+ should_install_traceback: d.InitVar[bool] = False
70
+ should_record: d.InitVar[bool] = False
71
+
72
+ rich_kwargs: d.InitVar[dict[str, h.Any] | None] = None
73
+
74
+ def __post_init__(
75
+ self,
76
+ name: str | None,
77
+ level: int,
78
+ should_store_memory_usage: bool,
79
+ message_width: int,
80
+ formatter: lggg.Formatter | None,
81
+ should_install_traceback: bool,
82
+ should_record: bool,
83
+ rich_kwargs: dict[str, h.Any] | None,
84
+ ) -> None:
85
+ """"""
86
+ lggg.Handler.__init__(self)
87
+
88
+ self.extension = handler_extension_t(
89
+ name=name,
90
+ should_store_memory_usage=should_store_memory_usage,
91
+ handler=self,
92
+ level=level,
93
+ message_width=message_width,
94
+ formatter=formatter,
95
+ )
96
+
97
+ if rich_kwargs is None:
98
+ rich_console_kwargs = {}
99
+ else:
100
+ rich_console_kwargs = rich_kwargs
101
+ rich_traceback_kwargs = {}
102
+ if should_install_traceback:
103
+ for key in rich_console_kwargs:
104
+ if key in _COMMON_TRACEBACK_ARGUMENTS:
105
+ rich_traceback_kwargs[key] = rich_console_kwargs[key]
106
+ elif key in _EXCLUSIVE_TRACEBACK_ARGUMENTS:
107
+ rich_traceback_kwargs[key] = rich_console_kwargs[key]
108
+ del rich_console_kwargs[key]
109
+
110
+ self.console = console_t(
111
+ highlight=False,
112
+ force_terminal=True,
113
+ record=should_record,
114
+ **rich_console_kwargs,
115
+ )
116
+ if should_install_traceback:
117
+ rich_traceback_kwargs["console"] = self.console
118
+ InstallTracebackHandler(**rich_traceback_kwargs)
119
+
120
+ self.MessageFromRecord = self.extension.MessageFromRecord
121
+ if self.alternating_lines == 1:
122
+ self.alternating_lines = 0
123
+ self.background_is_light = False
124
+ elif self.alternating_lines == 2:
125
+ self.alternating_lines = 0
126
+ self.background_is_light = True
127
+ else:
128
+ self.alternating_lines = -1
129
+
130
+ def emit(self, record: lggg.LogRecord, /) -> None:
131
+ """"""
132
+ if hasattr(record, SHOW_W_RULE_ATTR):
133
+ richer = Rule(record.msg, DATE_TIME_COLOR)
134
+ else:
135
+ message = self.MessageFromRecord(record, PreProcessed=EscapedVersion)
136
+ should_highlight_back = self.alternating_lines == 1
137
+ if self.alternating_lines >= 0:
138
+ self.alternating_lines = (self.alternating_lines + 1) % 2
139
+ richer = HighlightedVersion(
140
+ self.console,
141
+ message,
142
+ record.levelno,
143
+ should_highlight_back=should_highlight_back,
144
+ background_is_light=self.background_is_light,
145
+ )
146
+ self.console.print(richer, crop=False, overflow="ignore")
147
+
148
+ def ShowMessage(self, message: str | rule_t, /, *, indented: bool = False) -> None:
149
+ """
150
+ See documentation of
151
+ logger_36.catalog.handler.generic.generic_handler_t.ShowMessage.
152
+ """
153
+ if isinstance(message, str) and indented:
154
+ message = txt_.indent(message, LINE_INDENT)
155
+ self.console.print(message, crop=False, overflow="ignore")
156
+
157
+ def DisplayRule(self, /, *, text: str | None = None, color: str = "white") -> None:
158
+ """"""
159
+ self.ShowMessage(Rule(text, color))
160
+
161
+
162
+ def HighlightedVersion(
163
+ _: console_t,
164
+ message: str,
165
+ log_level: int,
166
+ /,
167
+ *,
168
+ should_highlight_back: bool = False,
169
+ background_is_light: bool = True,
170
+ ) -> renderable_t:
171
+ """"""
172
+ output = text_t(message, WHITE_COLOR)
173
+
174
+ output.stylize(LEVEL_COLOR[log_level], end=CONTEXT_LENGTH)
175
+ where = message.rfind(WHERE_SEPARATOR)
176
+ if (where >= 0) and ("\n" not in message[where:]):
177
+ output.stylize(GRAY_COLOR, start=where)
178
+ _ = output.highlight_words(ACTUAL_PATTERNS, style=ACTUAL_COLOR)
179
+ _ = output.highlight_regex(EXPECTED_PATTERNS, style=EXPECTED_COLOR)
180
+
181
+ if should_highlight_back:
182
+ if background_is_light:
183
+ style = ALTERNATIVE_BACKGROUND_FOR_LIGHT
184
+ else:
185
+ style = ALTERNATIVE_BACKGROUND_FOR_DARK
186
+ output.stylize(style)
187
+
188
+ return output
189
+
190
+
191
+ """
192
+ COPYRIGHT NOTICE
193
+
194
+ This software is governed by the CeCILL license under French law and
195
+ abiding by the rules of distribution of free software. You can use,
196
+ modify and/ or redistribute the software under the terms of the CeCILL
197
+ license as circulated by CEA, CNRS and INRIA at the following URL
198
+ "http://www.cecill.info".
199
+
200
+ As a counterpart to the access to the source code and rights to copy,
201
+ modify and redistribute granted by the license, users are provided only
202
+ with a limited warranty and the software's author, the holder of the
203
+ economic rights, and the successive licensors have only limited
204
+ liability.
205
+
206
+ In this respect, the user's attention is drawn to the risks associated
207
+ with loading, using, modifying and/or developing or reproducing the
208
+ software by the user in light of its specific status of free software,
209
+ that may mean that it is complicated to manipulate, and that also
210
+ therefore means that it is reserved for developers and experienced
211
+ professionals having in-depth computer knowledge. Users are therefore
212
+ encouraged to load and test the software's suitability as regards their
213
+ requirements in conditions enabling the security of their systems and/or
214
+ data to be ensured and, more generally, to use and operate it in the
215
+ same conditions as regards security.
216
+
217
+ The fact that you are presently reading this means that you have had
218
+ knowledge of the CeCILL license and that you accept its terms.
219
+
220
+ SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
221
+
222
+ This software is being developed by Eric Debreuve, a CNRS employee and
223
+ member of team Morpheme.
224
+ Team Morpheme is a joint team between Inria, CNRS, and UniCA.
225
+ It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
226
+ I3S, and Laboratory iBV.
227
+
228
+ CNRS: https://www.cnrs.fr/index.php/en
229
+ Inria: https://www.inria.fr/en/
230
+ UniCA: https://univ-cotedazur.eu/
231
+ Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
232
+ I3S: https://www.i3s.unice.fr/en/
233
+ iBV: http://ibv.unice.fr/
234
+ Team Morpheme: https://team.inria.fr/morpheme/
235
+ """