logger-36 2024.1__py3-none-any.whl → 2024.2__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 (41) hide show
  1. logger_36/__init__.py +2 -7
  2. logger_36/catalog/config/console_rich.py +49 -0
  3. logger_36/catalog/handler/console.py +80 -0
  4. logger_36/{type/console.py → catalog/handler/console_rich.py} +77 -52
  5. logger_36/catalog/handler/file.py +90 -0
  6. logger_36/catalog/handler/generic.py +150 -0
  7. logger_36/catalog/logging/chronos.py +39 -0
  8. logger_36/catalog/{gpu.py → logging/gpu.py} +3 -1
  9. logger_36/catalog/logging/memory.py +105 -0
  10. logger_36/catalog/{system.py → logging/system.py} +5 -27
  11. logger_36/config/issue.py +32 -0
  12. logger_36/config/memory.py +33 -0
  13. logger_36/{config.py → config/message.py} +14 -14
  14. logger_36/config/system.py +49 -0
  15. logger_36/constant/generic.py +37 -0
  16. logger_36/constant/handler.py +35 -0
  17. logger_36/constant/issue.py +35 -0
  18. logger_36/{type/file.py → constant/logger.py} +13 -15
  19. logger_36/constant/memory.py +39 -0
  20. logger_36/{constant.py → constant/message.py} +11 -15
  21. logger_36/constant/record.py +35 -0
  22. logger_36/constant/system.py +39 -0
  23. logger_36/instance.py +5 -5
  24. logger_36/main.py +130 -32
  25. logger_36/{catalog → task/format}/memory.py +34 -33
  26. logger_36/task/format/message.py +112 -0
  27. logger_36/task/format/rule.py +47 -0
  28. logger_36/task/inspection.py +18 -18
  29. logger_36/{measure → task/measure}/chronos.py +4 -2
  30. logger_36/task/storage.py +64 -3
  31. logger_36/type/extension.py +73 -61
  32. logger_36/type/issue.py +57 -0
  33. logger_36/type/logger.py +349 -0
  34. logger_36/version.py +1 -1
  35. {logger_36-2024.1.dist-info → logger_36-2024.2.dist-info}/METADATA +1 -2
  36. logger_36-2024.2.dist-info/RECORD +39 -0
  37. {logger_36-2024.1.dist-info → logger_36-2024.2.dist-info}/WHEEL +1 -1
  38. logger_36/type/generic.py +0 -115
  39. logger_36-2024.1.dist-info/RECORD +0 -21
  40. /logger_36/{measure → task/measure}/memory.py +0 -0
  41. {logger_36-2024.1.dist-info → logger_36-2024.2.dist-info}/top_level.txt +0 -0
logger_36/__init__.py CHANGED
@@ -29,16 +29,11 @@
29
29
  # The fact that you are presently reading this means that you have had
30
30
  # knowledge of the CeCILL license and that you accept its terms.
31
31
 
32
- import logging as lggg
33
-
34
32
  from logger_36.instance import LOGGER
35
33
  from logger_36.main import (
34
+ AddConsoleHandler,
36
35
  AddFileHandler,
37
36
  AddGenericHandler,
38
- SetExitOnError,
39
- SetLOGLevel,
37
+ AddRichConsoleHandler,
40
38
  )
41
- from logger_36.type.console import console_handler_t
42
39
  from logger_36.version import __version__
43
-
44
- LOGGER.addHandler(console_handler_t(level=lggg.INFO))
@@ -0,0 +1,49 @@
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 rich.color import Color as color_t
35
+ from rich.style import Style as style_t
36
+
37
+ DATE_TIME_COLOR: str = "dodger_blue2"
38
+ LEVEL_COLOR: dict[int, str | style_t] = {
39
+ lggg.DEBUG: "orchid",
40
+ lggg.INFO: "white",
41
+ lggg.WARNING: "yellow",
42
+ lggg.ERROR: "orange1",
43
+ lggg.CRITICAL: "red",
44
+ }
45
+ ACTUAL_COLOR: str = "red"
46
+ EXPECTED_COLOR: str = "green"
47
+ ELAPSED_TIME_COLOR: str = "green"
48
+
49
+ GRAY_STYLE: style_t = style_t(color=color_t.from_rgb(150, 150, 150))
@@ -0,0 +1,80 @@
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 dataclasses as dtcl
33
+ import logging as lggg
34
+ import typing as h
35
+
36
+ from logger_36.constant.record import SHOW_W_RULE_ATTR
37
+ from logger_36.task.format.rule import RuleAsText
38
+ from logger_36.type.extension import handler_extension_t
39
+
40
+
41
+ @dtcl.dataclass(slots=True, repr=False, eq=False)
42
+ class console_handler_t(lggg.Handler):
43
+ extension: handler_extension_t = dtcl.field(init=False)
44
+ FormattedLines: h.Callable[..., tuple[str, str | None]] = dtcl.field(init=False)
45
+
46
+ name: dtcl.InitVar[str | None] = None
47
+ level: dtcl.InitVar[int] = lggg.NOTSET
48
+ show_where: dtcl.InitVar[bool] = True
49
+ show_memory_usage: dtcl.InitVar[bool] = False
50
+ formatter: dtcl.InitVar[lggg.Formatter | None] = None
51
+
52
+ def __post_init__(
53
+ self,
54
+ name: str | None,
55
+ level: int,
56
+ show_where: bool,
57
+ show_memory_usage: bool,
58
+ formatter: lggg.Formatter | None,
59
+ ) -> None:
60
+ """"""
61
+ lggg.Handler.__init__(self)
62
+
63
+ self.extension = handler_extension_t(
64
+ name=name,
65
+ show_where=show_where,
66
+ show_memory_usage=show_memory_usage,
67
+ handler=self,
68
+ level=level,
69
+ formatter=formatter,
70
+ )
71
+
72
+ self.FormattedLines = self.extension.FormattedLines
73
+
74
+ def emit(self, record: lggg.LogRecord, /) -> None:
75
+ """"""
76
+ if hasattr(record, SHOW_W_RULE_ATTR):
77
+ message = RuleAsText(record.msg)
78
+ else:
79
+ message, _ = self.FormattedLines(record, should_join_lines=True)
80
+ print(message)
@@ -29,68 +29,95 @@
29
29
  # The fact that you are presently reading this means that you have had
30
30
  # knowledge of the CeCILL license and that you accept its terms.
31
31
 
32
+ import dataclasses as dtcl
32
33
  import logging as lggg
33
- from typing import ClassVar
34
-
35
- from rich.color import Color as color_t
34
+ import typing as h
35
+
36
+ from logger_36.catalog.config.console_rich import (
37
+ ACTUAL_COLOR,
38
+ DATE_TIME_COLOR,
39
+ ELAPSED_TIME_COLOR,
40
+ EXPECTED_COLOR,
41
+ GRAY_STYLE,
42
+ LEVEL_COLOR,
43
+ )
44
+ from logger_36.config.message import (
45
+ ACTUAL_PATTERNS,
46
+ ELAPSED_TIME_SEPARATOR,
47
+ EXPECTED_PATTERNS,
48
+ LEVEL_CLOSING,
49
+ WHERE_SEPARATOR,
50
+ )
51
+ from logger_36.constant.message import TIME_LENGTH
52
+ from logger_36.constant.record import SHOW_W_RULE_ATTR
53
+ from logger_36.task.format.rule import Rule
54
+ from logger_36.type.extension import handler_extension_t
36
55
  from rich.console import Console as console_t
37
- from rich.markup import escape as PreProcessedForRich
38
- from rich.style import Style as style_t
56
+ from rich.console import RenderableType as renderable_t
57
+ from rich.markup import escape as EscapedForRich
39
58
  from rich.text import Text as text_t
40
59
 
41
- from logger_36.config import ELAPSED_TIME_SEPARATOR, LEVEL_CLOSING, WHERE_SEPARATOR
42
- from logger_36.constant import DATE_TIME_LENGTH
43
- from logger_36.type.extension import handler_extension_t
44
-
45
60
 
46
- class console_handler_t(lggg.Handler, handler_extension_t):
47
- TAB_SIZE: ClassVar[int] = 5 # => CONTEXT_SEPARATOR aligned for all log levels.
48
- DATE_TIME_COLOR: ClassVar[str] = "dodger_blue2"
49
- LEVEL_COLOR: ClassVar[dict[int, str | style_t]] = {
50
- lggg.DEBUG: "orchid",
51
- lggg.INFO: "white",
52
- lggg.WARNING: "yellow",
53
- lggg.ERROR: "orange1",
54
- lggg.CRITICAL: "red",
55
- }
56
- ELAPSED_TIME_COLOR: ClassVar[str] = "green"
57
- ACTUAL_COLOR: ClassVar[str] = "red"
58
- EXPECTED_COLOR: ClassVar[str] = "green"
59
- GRAY_STYLE: ClassVar[style_t] = style_t(color=color_t.from_rgb(150, 150, 150))
60
- ACTUAL_PATTERNS: ClassVar[tuple[str]] = (r" Actual=[^.]+;",)
61
- EXPECTED_PATTERNS: ClassVar[tuple[str]] = (r" Expected([!<>]=|: )[^.]+\.",)
62
-
63
- console: console_t
64
-
65
- def __init__(self, /, *, level: int = lggg.NOTSET) -> None:
61
+ @dtcl.dataclass(slots=True, repr=False, eq=False)
62
+ class console_rich_handler_t(lggg.Handler):
63
+ extension: handler_extension_t = dtcl.field(init=False)
64
+ console: console_t = dtcl.field(init=False)
65
+ FormattedLines: h.Callable[..., tuple[str, str | None]] = dtcl.field(init=False)
66
+
67
+ name: dtcl.InitVar[str | None] = None
68
+ level: dtcl.InitVar[int] = lggg.NOTSET
69
+ show_where: dtcl.InitVar[bool] = True
70
+ show_memory_usage: dtcl.InitVar[bool] = False
71
+ formatter: dtcl.InitVar[lggg.Formatter | None] = None
72
+
73
+ rich_kwargs: dtcl.InitVar[dict[str, h.Any] | None] = None
74
+
75
+ def __post_init__(
76
+ self,
77
+ name: str | None,
78
+ level: int,
79
+ show_where: bool,
80
+ show_memory_usage: bool,
81
+ formatter: lggg.Formatter | None,
82
+ rich_kwargs: dict[str, h.Any] | None,
83
+ ) -> None:
66
84
  """"""
67
- lggg.Handler.__init__(self, level=level)
68
- handler_extension_t.__init__(self)
85
+ lggg.Handler.__init__(self)
86
+
87
+ self.extension = handler_extension_t(
88
+ name=name,
89
+ show_where=show_where,
90
+ show_memory_usage=show_memory_usage,
91
+ handler=self,
92
+ level=level,
93
+ formatter=formatter,
94
+ )
69
95
 
70
- self.setFormatter(self.formatter)
96
+ if rich_kwargs is None:
97
+ rich_kwargs = {}
71
98
  self.console = console_t(
72
- tab_size=self.__class__.TAB_SIZE,
73
99
  highlight=False,
74
100
  force_terminal=True,
75
101
  record=True,
102
+ **rich_kwargs,
76
103
  )
77
104
 
105
+ self.FormattedLines = self.extension.FormattedLines
106
+
78
107
  def emit(self, record: lggg.LogRecord, /) -> None:
79
108
  """"""
80
- first_line, next_lines = self.MessageLines(
81
- record, PreProcessed=PreProcessedForRich
82
- )
83
- highlighted = self.__class__.HighlightedVersion(
84
- first_line, next_lines, record.levelno
85
- )
86
- self.console.print(highlighted, crop=False, overflow="ignore")
87
-
88
- self.ExitOrNotIfError(record)
109
+ cls = self.__class__
110
+ if hasattr(record, SHOW_W_RULE_ATTR):
111
+ richer = Rule(record.msg, DATE_TIME_COLOR)
112
+ else:
113
+ first, next_s = self.FormattedLines(record, PreProcessed=EscapedForRich)
114
+ richer = cls.HighlightedVersion(first, next_s, record.levelno)
115
+ self.console.print(richer, crop=False, overflow="ignore")
89
116
 
90
117
  @classmethod
91
118
  def HighlightedVersion(
92
119
  cls, first_line: str, next_lines: str | None, log_level: int, /
93
- ) -> text_t:
120
+ ) -> renderable_t:
94
121
  """"""
95
122
  output = text_t(first_line)
96
123
 
@@ -102,21 +129,19 @@ class console_handler_t(lggg.Handler, handler_extension_t):
102
129
  WHERE_SEPARATOR, context_end, elapsed_time_separator
103
130
  )
104
131
 
105
- output.stylize(cls.DATE_TIME_COLOR, end=DATE_TIME_LENGTH)
132
+ output.stylize(DATE_TIME_COLOR, end=TIME_LENGTH)
106
133
  output.stylize(
107
- cls.LEVEL_COLOR[log_level],
108
- start=DATE_TIME_LENGTH,
134
+ LEVEL_COLOR[log_level],
135
+ start=TIME_LENGTH,
109
136
  end=context_end + 1,
110
137
  )
111
- output.stylize(
112
- cls.GRAY_STYLE, start=where_separator, end=elapsed_time_separator
113
- )
114
- output.stylize(cls.ELAPSED_TIME_COLOR, start=elapsed_time_separator)
138
+ output.stylize(GRAY_STYLE, start=where_separator, end=elapsed_time_separator)
139
+ output.stylize(ELAPSED_TIME_COLOR, start=elapsed_time_separator)
115
140
 
116
141
  if next_lines is not None:
117
142
  output.append(next_lines)
118
143
 
119
- output.highlight_words(cls.ACTUAL_PATTERNS, style=cls.ACTUAL_COLOR)
120
- output.highlight_words(cls.EXPECTED_PATTERNS, style=cls.EXPECTED_COLOR)
144
+ _ = output.highlight_regex(ACTUAL_PATTERNS, style=ACTUAL_COLOR)
145
+ _ = output.highlight_regex(EXPECTED_PATTERNS, style=EXPECTED_COLOR)
121
146
 
122
147
  return output
@@ -0,0 +1,90 @@
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 dataclasses as dtcl
33
+ import logging as lggg
34
+ import typing as h
35
+ from pathlib import Path as path_t
36
+
37
+ from logger_36.constant.record import SHOW_W_RULE_ATTR
38
+ from logger_36.task.format.rule import RuleAsText
39
+ from logger_36.type.extension import handler_extension_t
40
+
41
+
42
+ @dtcl.dataclass(slots=True, repr=False, eq=False)
43
+ class file_handler_t(lggg.FileHandler):
44
+
45
+ extension: handler_extension_t = dtcl.field(init=False)
46
+ FormattedLines: h.Callable[..., tuple[str, str | None]] = dtcl.field(init=False)
47
+
48
+ name: dtcl.InitVar[str | None] = None
49
+ level: dtcl.InitVar[int] = lggg.NOTSET
50
+ show_where: dtcl.InitVar[bool] = True
51
+ show_memory_usage: dtcl.InitVar[bool] = False
52
+ formatter: dtcl.InitVar[lggg.Formatter | None] = None
53
+
54
+ path: dtcl.InitVar[path_t | None] = None
55
+ handler_args: dtcl.InitVar[tuple[h.Any, ...] | None] = None
56
+ handler_kwargs: dtcl.InitVar[dict[str, h.Any] | None] = None
57
+
58
+ def __post_init__(
59
+ self,
60
+ name: str | None,
61
+ level: int,
62
+ show_where: bool,
63
+ show_memory_usage: bool,
64
+ formatter: lggg.Formatter | None,
65
+ path: path_t | None,
66
+ handler_args: tuple[h.Any],
67
+ handler_kwargs: dict[str, h.Any] | None,
68
+ ) -> None:
69
+ """"""
70
+ lggg.FileHandler.__init__(self, path, *handler_args, **handler_kwargs)
71
+
72
+ self.extension = handler_extension_t(
73
+ name=name,
74
+ show_where=show_where,
75
+ show_memory_usage=show_memory_usage,
76
+ handler=self,
77
+ level=level,
78
+ formatter=formatter,
79
+ )
80
+
81
+ self.FormattedLines = self.extension.FormattedLines
82
+
83
+ def emit(self, record: lggg.LogRecord, /) -> None:
84
+ """"""
85
+ if hasattr(record, SHOW_W_RULE_ATTR):
86
+ message = RuleAsText(record.msg)
87
+ else:
88
+ message, _ = self.FormattedLines(record, should_join_lines=True)
89
+ print(message, file=self.stream)
90
+ self.stream.flush()
@@ -0,0 +1,150 @@
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 dataclasses as dtcl
33
+ import logging as lggg
34
+ import typing as h
35
+
36
+ try:
37
+ from rich.console import Console as console_t
38
+ from rich.markup import escape as EscapedForRich
39
+ from rich.terminal_theme import DEFAULT_TERMINAL_THEME
40
+ except ModuleNotFoundError:
41
+ console_t = EscapedForRich = DEFAULT_TERMINAL_THEME = None
42
+
43
+ from logger_36.catalog.handler.console_rich import console_rich_handler_t
44
+ from logger_36.constant.record import SHOW_W_RULE_ATTR
45
+ from logger_36.task.format.rule import Rule
46
+ from logger_36.type.extension import handler_extension_t
47
+
48
+
49
+ class can_show_message_p(h.Protocol):
50
+ def ShowMessage(self, message: str, /) -> None: ...
51
+
52
+
53
+ interface_h = can_show_message_p | h.Callable[[str], None]
54
+
55
+
56
+ @dtcl.dataclass(slots=True, repr=False, eq=False)
57
+ class generic_handler_t(lggg.Handler):
58
+
59
+ extension: handler_extension_t = dtcl.field(init=False)
60
+ console: console_t | None = None
61
+ FormattedLines: h.Callable[..., tuple[str, str | None]] = dtcl.field(init=False)
62
+ ShowMessage: h.Callable[[str], None] = lambda _arg: None
63
+
64
+ name: dtcl.InitVar[str | None] = None
65
+ level: dtcl.InitVar[int] = lggg.NOTSET
66
+ show_where: dtcl.InitVar[bool] = True
67
+ show_memory_usage: dtcl.InitVar[bool] = False
68
+ formatter: dtcl.InitVar[lggg.Formatter | None] = None
69
+
70
+ supports_html: dtcl.InitVar[bool] = False
71
+ rich_kwargs: dtcl.InitVar[dict[str, h.Any] | None] = None
72
+ interface: dtcl.InitVar[interface_h | None] = None
73
+
74
+ def __post_init__(
75
+ self,
76
+ name: str | None,
77
+ level: int,
78
+ show_where: bool,
79
+ show_memory_usage: bool,
80
+ formatter: lggg.Formatter | None,
81
+ supports_html: bool,
82
+ rich_kwargs: dict[str, h.Any] | None,
83
+ interface: interface_h | None,
84
+ ) -> None:
85
+ """"""
86
+ lggg.Handler.__init__(self)
87
+
88
+ self.extension = handler_extension_t(
89
+ name=name,
90
+ show_where=show_where,
91
+ show_memory_usage=show_memory_usage,
92
+ handler=self,
93
+ level=level,
94
+ formatter=formatter,
95
+ )
96
+
97
+ if supports_html and (console_t is not None):
98
+ if rich_kwargs is None:
99
+ rich_kwargs = {}
100
+ self.console = console_t(
101
+ highlight=False,
102
+ force_terminal=True,
103
+ **rich_kwargs,
104
+ )
105
+
106
+ self.FormattedLines = self.extension.FormattedLines
107
+
108
+ if interface is None:
109
+ raise ValueError("Interface cannot be None.")
110
+ self.ShowMessage = getattr(
111
+ interface, can_show_message_p.ShowMessage.__name__, interface
112
+ )
113
+
114
+ def emit(self, record: lggg.LogRecord, /) -> None:
115
+ """"""
116
+ if self.console is None:
117
+ message, _ = self.FormattedLines(record, should_join_lines=True)
118
+ else:
119
+ if hasattr(record, SHOW_W_RULE_ATTR):
120
+ richer = Rule(record.msg, console_rich_handler_t.DATE_TIME_COLOR)
121
+ else:
122
+ first, next_s = self.FormattedLines(record, PreProcessed=EscapedForRich)
123
+ richer = console_rich_handler_t.HighlightedVersion(
124
+ first, next_s, record.levelno
125
+ )
126
+ segments = self.console.render(richer)
127
+
128
+ # Inspired from the code of: rich.console.export_html.
129
+ html_segments = []
130
+ for text, style, _ in segments:
131
+ if text == "\n":
132
+ html_segments.append("\n")
133
+ else:
134
+ if style is not None:
135
+ style = style.get_html_style(DEFAULT_TERMINAL_THEME)
136
+ if (style is not None) and (style.__len__() > 0):
137
+ text = f'<span style="{style}">{text}</span>'
138
+ html_segments.append(text)
139
+ if html_segments[-1] == "\n":
140
+ html_segments = html_segments[:-1]
141
+
142
+ # /!\ For some reason, the widget splits the message into lines, place each
143
+ # line inside a pre tag, and set margin-bottom of the first and list lines
144
+ # to 12px. This can be seen by printing self.contents.toHtml(). To avoid the
145
+ # unwanted extra margins, margin-bottom is set to 0 below.
146
+ message = (
147
+ "<pre style='margin-bottom:0px'>" + "".join(html_segments) + "</pre>"
148
+ )
149
+
150
+ self.ShowMessage(message)
@@ -0,0 +1,39 @@
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
+ from logger_36.constant.handler import HIDE_WHERE_KWARG
33
+ from logger_36.instance import LOGGER
34
+ from logger_36.task.measure.chronos import ElapsedTime
35
+
36
+
37
+ def LogElapsedTime() -> None:
38
+ """"""
39
+ LOGGER.info(f"Elapsed Time: {ElapsedTime()}", **HIDE_WHERE_KWARG)
@@ -29,6 +29,7 @@
29
29
  # The fact that you are presently reading this means that you have had
30
30
  # knowledge of the CeCILL license and that you accept its terms.
31
31
 
32
+ from logger_36.constant.handler import HIDE_WHERE_KWARG
32
33
  from logger_36.instance import LOGGER
33
34
 
34
35
  try:
@@ -52,5 +53,6 @@ def LogGPURelatedDetails() -> None:
52
53
  f" CuDNN: {system_details['cudnn_version']}\n"
53
54
  f" Tensorflow: {tsfl.version.VERSION}\n"
54
55
  f" Tensorflow Build: {tsfl.sysconfig.get_build_info()}\n"
55
- f" TensorRT: {tsrt.__version__}"
56
+ f" TensorRT: {tsrt.__version__}",
57
+ **HIDE_WHERE_KWARG,
56
58
  )