logger-36 2024.28__py3-none-any.whl → 2024.29__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.
@@ -25,7 +25,6 @@ LEVEL_COLOR: dict[int, str | style_t] = {
25
25
  ACTUAL_COLOR = LEVEL_COLOR[lggg.CRITICAL]
26
26
  EXPECTED_COLOR = "green3"
27
27
  DATE_TIME_COLOR = "sky_blue3"
28
- ELAPSED_TIME_COLOR = DATE_TIME_COLOR
29
28
 
30
29
  ALTERNATIVE_BACKGROUND_FOR_LIGHT = style_t(bgcolor=color_t.from_rgb(230, 230, 230))
31
30
  ALTERNATIVE_BACKGROUND_FOR_DARK = style_t(bgcolor=color_t.from_rgb(25, 25, 25))
@@ -18,12 +18,11 @@ from logger_36.type.handler import handler_extension_t
18
18
  @d.dataclass(slots=True, repr=False, eq=False)
19
19
  class console_handler_t(lggg.Handler):
20
20
  extension: handler_extension_t = d.field(init=False)
21
- FormattedLines: h.Callable[..., tuple[str, str | None]] = d.field(init=False)
21
+ MessageFromRecord: h.Callable[..., tuple[str, str | None]] = d.field(init=False)
22
22
 
23
23
  name: d.InitVar[str | None] = None
24
24
  level: d.InitVar[int] = lggg.NOTSET
25
- show_where: d.InitVar[bool] = True
26
- show_memory_usage: d.InitVar[bool] = False
25
+ should_store_memory_usage: d.InitVar[bool] = False
27
26
  message_width: d.InitVar[int] = -1
28
27
  formatter: d.InitVar[lggg.Formatter | None] = None
29
28
 
@@ -31,8 +30,7 @@ class console_handler_t(lggg.Handler):
31
30
  self,
32
31
  name: str | None,
33
32
  level: int,
34
- show_where: bool,
35
- show_memory_usage: bool,
33
+ should_store_memory_usage: bool,
36
34
  message_width: int,
37
35
  formatter: lggg.Formatter | None,
38
36
  ) -> None:
@@ -41,22 +39,21 @@ class console_handler_t(lggg.Handler):
41
39
 
42
40
  self.extension = handler_extension_t(
43
41
  name=name,
44
- show_where=show_where,
45
- show_memory_usage=show_memory_usage,
42
+ should_store_memory_usage=should_store_memory_usage,
46
43
  handler=self,
47
44
  level=level,
48
45
  message_width=message_width,
49
46
  formatter=formatter,
50
47
  )
51
48
 
52
- self.FormattedLines = self.extension.FormattedLines
49
+ self.MessageFromRecord = self.extension.MessageFromRecord
53
50
 
54
51
  def emit(self, record: lggg.LogRecord, /) -> None:
55
52
  """"""
56
53
  if hasattr(record, SHOW_W_RULE_ATTR):
57
54
  message = RuleAsText(record.msg)
58
55
  else:
59
- message, _ = self.FormattedLines(record, should_join_lines=True)
56
+ message = self.MessageFromRecord(record)
60
57
  print(message)
61
58
 
62
59
  def ShowMessage(self, message: str, /, *, indented: bool = False) -> None:
@@ -14,20 +14,13 @@ from logger_36.catalog.config.console_rich import (
14
14
  ALTERNATIVE_BACKGROUND_FOR_DARK,
15
15
  ALTERNATIVE_BACKGROUND_FOR_LIGHT,
16
16
  DATE_TIME_COLOR,
17
- ELAPSED_TIME_COLOR,
18
17
  EXPECTED_COLOR,
19
18
  GRAY_COLOR,
20
19
  LEVEL_COLOR,
21
20
  WHITE_COLOR,
22
21
  )
23
- from logger_36.config.message import (
24
- ACTUAL_PATTERNS,
25
- ELAPSED_TIME_SEPARATOR,
26
- EXPECTED_PATTERNS,
27
- LEVEL_CLOSING,
28
- WHERE_SEPARATOR,
29
- )
30
- from logger_36.constant.message import LINE_INDENT
22
+ from logger_36.config.message import ACTUAL_PATTERNS, EXPECTED_PATTERNS, WHERE_SEPARATOR
23
+ from logger_36.constant.message import CONTEXT_LENGTH, LINE_INDENT
31
24
  from logger_36.constant.record import SHOW_W_RULE_ATTR
32
25
  from logger_36.task.format.rule import Rule
33
26
  from logger_36.type.handler import handler_extension_t
@@ -64,14 +57,13 @@ class console_rich_handler_t(lggg.Handler):
64
57
 
65
58
  extension: handler_extension_t = d.field(init=False)
66
59
  console: console_t = d.field(init=False)
67
- FormattedLines: h.Callable[..., tuple[str, str | None]] = d.field(init=False)
60
+ MessageFromRecord: h.Callable[..., str] = d.field(init=False)
68
61
  alternating_lines: int = 0
69
62
  background_is_light: bool = True
70
63
 
71
64
  name: d.InitVar[str | None] = None
72
65
  level: d.InitVar[int] = lggg.NOTSET
73
- show_where: d.InitVar[bool] = True
74
- show_memory_usage: d.InitVar[bool] = False
66
+ should_store_memory_usage: d.InitVar[bool] = False
75
67
  message_width: d.InitVar[int] = -1
76
68
  formatter: d.InitVar[lggg.Formatter | None] = None
77
69
  should_install_traceback: d.InitVar[bool] = False
@@ -83,8 +75,7 @@ class console_rich_handler_t(lggg.Handler):
83
75
  self,
84
76
  name: str | None,
85
77
  level: int,
86
- show_where: bool,
87
- show_memory_usage: bool,
78
+ should_store_memory_usage: bool,
88
79
  message_width: int,
89
80
  formatter: lggg.Formatter | None,
90
81
  should_install_traceback: bool,
@@ -96,8 +87,7 @@ class console_rich_handler_t(lggg.Handler):
96
87
 
97
88
  self.extension = handler_extension_t(
98
89
  name=name,
99
- show_where=show_where,
100
- show_memory_usage=show_memory_usage,
90
+ should_store_memory_usage=should_store_memory_usage,
101
91
  handler=self,
102
92
  level=level,
103
93
  message_width=message_width,
@@ -127,7 +117,7 @@ class console_rich_handler_t(lggg.Handler):
127
117
  rich_traceback_kwargs["console"] = self.console
128
118
  InstallTracebackHandler(**rich_traceback_kwargs)
129
119
 
130
- self.FormattedLines = self.extension.FormattedLines
120
+ self.MessageFromRecord = self.extension.MessageFromRecord
131
121
  if self.alternating_lines == 1:
132
122
  self.alternating_lines = 0
133
123
  self.background_is_light = False
@@ -142,14 +132,13 @@ class console_rich_handler_t(lggg.Handler):
142
132
  if hasattr(record, SHOW_W_RULE_ATTR):
143
133
  richer = Rule(record.msg, DATE_TIME_COLOR)
144
134
  else:
145
- first, next_s = self.FormattedLines(record, PreProcessed=EscapedVersion)
135
+ message = self.MessageFromRecord(record, PreProcessed=EscapedVersion)
146
136
  should_highlight_back = self.alternating_lines == 1
147
137
  if self.alternating_lines >= 0:
148
138
  self.alternating_lines = (self.alternating_lines + 1) % 2
149
139
  richer = HighlightedVersion(
150
140
  self.console,
151
- first,
152
- next_s,
141
+ message,
153
142
  record.levelno,
154
143
  should_highlight_back=should_highlight_back,
155
144
  background_is_light=self.background_is_light,
@@ -172,8 +161,7 @@ class console_rich_handler_t(lggg.Handler):
172
161
 
173
162
  def HighlightedVersion(
174
163
  _: console_t,
175
- first_line: str,
176
- next_lines: str | None,
164
+ message: str,
177
165
  log_level: int,
178
166
  /,
179
167
  *,
@@ -181,24 +169,13 @@ def HighlightedVersion(
181
169
  background_is_light: bool = True,
182
170
  ) -> renderable_t:
183
171
  """"""
184
- output = text_t(first_line, WHITE_COLOR)
185
-
186
- # Used instead of _CONTEXT_LENGTH which might include \t, thus creating a
187
- # mismatch between character length and length when displayed in console.
188
- context_end = first_line.find(LEVEL_CLOSING)
189
- elapsed_time_separator = first_line.rfind(ELAPSED_TIME_SEPARATOR)
190
- where_separator = first_line.rfind(
191
- WHERE_SEPARATOR, context_end, elapsed_time_separator
192
- )
193
-
194
- output.stylize(LEVEL_COLOR[log_level], end=context_end + 1)
195
- output.stylize(GRAY_COLOR, start=where_separator, end=elapsed_time_separator)
196
- output.stylize(ELAPSED_TIME_COLOR, start=elapsed_time_separator)
197
-
198
- if next_lines is not None:
199
- output.append(next_lines)
172
+ output = text_t(message, WHITE_COLOR)
200
173
 
201
- _ = output.highlight_regex(ACTUAL_PATTERNS, style=ACTUAL_COLOR)
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)
202
179
  _ = output.highlight_regex(EXPECTED_PATTERNS, style=EXPECTED_COLOR)
203
180
 
204
181
  if should_highlight_back:
@@ -20,12 +20,11 @@ from logger_36.type.handler import handler_extension_t
20
20
  class file_handler_t(lggg.FileHandler):
21
21
 
22
22
  extension: handler_extension_t = d.field(init=False)
23
- FormattedLines: h.Callable[..., tuple[str, str | None]] = d.field(init=False)
23
+ MessageFromRecord: h.Callable[..., tuple[str, str | None]] = d.field(init=False)
24
24
 
25
25
  name: d.InitVar[str | None] = None
26
26
  level: d.InitVar[int] = lggg.NOTSET
27
- show_where: d.InitVar[bool] = True
28
- show_memory_usage: d.InitVar[bool] = False
27
+ should_store_memory_usage: d.InitVar[bool] = False
29
28
  message_width: d.InitVar[int] = -1
30
29
  formatter: d.InitVar[lggg.Formatter | None] = None
31
30
 
@@ -37,8 +36,7 @@ class file_handler_t(lggg.FileHandler):
37
36
  self,
38
37
  name: str | None,
39
38
  level: int,
40
- show_where: bool,
41
- show_memory_usage: bool,
39
+ should_store_memory_usage: bool,
42
40
  message_width: int,
43
41
  formatter: lggg.Formatter | None,
44
42
  path: path_t | None,
@@ -50,22 +48,21 @@ class file_handler_t(lggg.FileHandler):
50
48
 
51
49
  self.extension = handler_extension_t(
52
50
  name=name,
53
- show_where=show_where,
54
- show_memory_usage=show_memory_usage,
51
+ should_store_memory_usage=should_store_memory_usage,
55
52
  handler=self,
56
53
  level=level,
57
54
  message_width=message_width,
58
55
  formatter=formatter,
59
56
  )
60
57
 
61
- self.FormattedLines = self.extension.FormattedLines
58
+ self.MessageFromRecord = self.extension.MessageFromRecord
62
59
 
63
60
  def emit(self, record: lggg.LogRecord, /) -> None:
64
61
  """"""
65
62
  if hasattr(record, SHOW_W_RULE_ATTR):
66
63
  message = RuleAsText(record.msg)
67
64
  else:
68
- message, _ = self.FormattedLines(record, should_join_lines=True)
65
+ message = self.MessageFromRecord(record)
69
66
  print(message, file=self.stream)
70
67
  self.stream.flush()
71
68
 
@@ -60,12 +60,11 @@ class generic_handler_t(lggg.Handler):
60
60
 
61
61
  DisplayRule: display_rule_p = d.field(init=False)
62
62
  extension: handler_extension_t = d.field(init=False)
63
- FormattedLines: h.Callable[..., tuple[str, str | None]] = d.field(init=False)
63
+ MessageFromRecord: h.Callable[..., tuple[str, str | None]] = d.field(init=False)
64
64
 
65
65
  name: d.InitVar[str | None] = None
66
66
  level: d.InitVar[int] = lggg.NOTSET
67
- show_where: d.InitVar[bool] = True
68
- show_memory_usage: d.InitVar[bool] = False
67
+ should_store_memory_usage: d.InitVar[bool] = False
69
68
  message_width: d.InitVar[int] = -1
70
69
  formatter: d.InitVar[lggg.Formatter | None] = None
71
70
 
@@ -77,8 +76,7 @@ class generic_handler_t(lggg.Handler):
77
76
  self,
78
77
  name: str | None,
79
78
  level: int,
80
- show_where: bool,
81
- show_memory_usage: bool,
79
+ should_store_memory_usage: bool,
82
80
  message_width: int,
83
81
  formatter: lggg.Formatter | None,
84
82
  supports_html: bool,
@@ -90,8 +88,7 @@ class generic_handler_t(lggg.Handler):
90
88
 
91
89
  self.extension = handler_extension_t(
92
90
  name=name,
93
- show_where=show_where,
94
- show_memory_usage=show_memory_usage,
91
+ should_store_memory_usage=should_store_memory_usage,
95
92
  handler=self,
96
93
  level=level,
97
94
  message_width=message_width,
@@ -114,7 +111,7 @@ class generic_handler_t(lggg.Handler):
114
111
  else:
115
112
  self.DisplayRule = self._DisplayRuleAsText
116
113
 
117
- self.FormattedLines = self.extension.FormattedLines
114
+ self.MessageFromRecord = self.extension.MessageFromRecord
118
115
  if self.alternating_lines == 1:
119
116
  self.alternating_lines = 0
120
117
  self.background_is_light = False
@@ -130,19 +127,18 @@ class generic_handler_t(lggg.Handler):
130
127
  if hasattr(record, SHOW_W_RULE_ATTR):
131
128
  message = RuleAsText(record.msg)
132
129
  else:
133
- message, _ = self.FormattedLines(record, should_join_lines=True)
130
+ message = self.MessageFromRecord(record)
134
131
  else:
135
132
  if hasattr(record, SHOW_W_RULE_ATTR):
136
133
  richer = Rule(record.msg, DATE_TIME_COLOR)
137
134
  else:
138
- first, next_s = self.FormattedLines(record, PreProcessed=EscapedForRich)
135
+ message = self.MessageFromRecord(record, PreProcessed=EscapedForRich)
139
136
  should_highlight_back = self.alternating_lines == 1
140
137
  if self.alternating_lines >= 0:
141
138
  self.alternating_lines = (self.alternating_lines + 1) % 2
142
139
  richer = HighlightedVersion(
143
140
  self.console,
144
- first,
145
- next_s,
141
+ message,
146
142
  record.levelno,
147
143
  should_highlight_back=should_highlight_back,
148
144
  background_is_light=self.background_is_light,
@@ -4,7 +4,6 @@ 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 HIDE_WHERE_KWARG
8
7
  from logger_36.instance.logger import LOGGER
9
8
  from logger_36.task.measure.chronos import ElapsedTime
10
9
  from logger_36.type.logger import logger_t
@@ -12,7 +11,7 @@ from logger_36.type.logger import logger_t
12
11
 
13
12
  def LogElapsedTime(*, logger: logger_t = LOGGER) -> None:
14
13
  """"""
15
- logger.info(f"Elapsed Time: {ElapsedTime()}", **HIDE_WHERE_KWARG)
14
+ logger.info(f"Elapsed Time: {ElapsedTime()}")
16
15
 
17
16
 
18
17
  """
@@ -7,7 +7,6 @@ SEE COPYRIGHT NOTICE BELOW
7
7
  import sys as sstm
8
8
 
9
9
  from logger_36.constant.error import GPU_LOGGING_ERROR
10
- from logger_36.constant.logger import HIDE_WHERE_KWARG
11
10
  from logger_36.instance.logger import LOGGER
12
11
  from logger_36.type.logger import logger_t
13
12
 
@@ -41,7 +40,6 @@ def LogGPURelatedDetails(*, logger: logger_t = LOGGER) -> None:
41
40
  f" Tensorflow: {tsfl.version.VERSION}\n"
42
41
  f" Tensorflow Build: {tsfl.sysconfig.get_build_info()}\n"
43
42
  f" TensorRT: {tsrt.__version__}",
44
- **HIDE_WHERE_KWARG,
45
43
  )
46
44
 
47
45
 
@@ -5,11 +5,10 @@ SEE COPYRIGHT NOTICE BELOW
5
5
  """
6
6
 
7
7
  from logger_36.config.memory import LENGTH_100, MAX_N_SAMPLES
8
- from logger_36.constant.logger import HIDE_WHERE_KWARG
9
8
  from logger_36.constant.memory import storage_units_h
10
9
  from logger_36.instance.logger import LOGGER
11
10
  from logger_36.task.format.memory import FormattedUsage, UsageBar
12
- from logger_36.task.format.message import FormattedMessage
11
+ from logger_36.task.format.message import MessageWithActualExpected
13
12
  from logger_36.type.logger import logger_t
14
13
 
15
14
 
@@ -22,7 +21,7 @@ def LogMemoryUsages(
22
21
  logger: logger_t = LOGGER,
23
22
  ) -> None:
24
23
  """"""
25
- if not logger.any_handler_shows_memory:
24
+ if not logger.any_handler_stores_memory:
26
25
  return
27
26
 
28
27
  where_s, usages = zip(*logger.memory_usages)
@@ -34,7 +33,7 @@ def LogMemoryUsages(
34
33
  if isinstance(max_n_samples, int):
35
34
  if max_n_samples < 1:
36
35
  raise ValueError(
37
- FormattedMessage(
36
+ MessageWithActualExpected(
38
37
  "Invalid maximum number of samples",
39
38
  actual=max_n_samples,
40
39
  expected=1,
@@ -65,7 +64,7 @@ def LogMemoryUsages(
65
64
  )
66
65
  plot = "\n".join(plot)
67
66
 
68
- logger.info(title + plot, **HIDE_WHERE_KWARG)
67
+ logger.info(title + plot)
69
68
 
70
69
 
71
70
  def LogMaximumMemoryUsage(
@@ -77,12 +76,10 @@ def LogMaximumMemoryUsage(
77
76
  """
78
77
  unit: b or None=bytes, k=kilo, m=mega, g=giga, a=auto
79
78
  """
80
- if logger.any_handler_shows_memory:
79
+ if logger.any_handler_stores_memory:
81
80
  where, max_usage = logger.max_memory_usage_full
82
81
  value, unit = FormattedUsage(max_usage, unit=unit, decimals=decimals)
83
- logger.info(
84
- f"Max. Memory Usage: {value}{unit} near {where}", **HIDE_WHERE_KWARG
85
- )
82
+ logger.info(f"Max. Memory Usage: {value}{unit} near {where}")
86
83
 
87
84
 
88
85
  """
@@ -4,7 +4,6 @@ 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 HIDE_WHERE_KWARG
8
7
  from logger_36.constant.system import MAX_DETAIL_NAME_LENGTH, SYSTEM_DETAILS_AS_DICT
9
8
  from logger_36.instance.logger import LOGGER
10
9
  from logger_36.task.inspection import Modules
@@ -35,7 +34,6 @@ def LogSystemDetails(
35
34
  f"{details}\n"
36
35
  f" {'Python Modules':>{MAX_DETAIL_NAME_LENGTH}}:\n"
37
36
  f"{modules}",
38
- **HIDE_WHERE_KWARG,
39
37
  )
40
38
 
41
39
 
@@ -12,7 +12,7 @@ from logger_36.catalog.handler.file import file_handler_t
12
12
  from logger_36.catalog.handler.generic import generic_handler_t
13
13
  from logger_36.constant.handler import HANDLER_CODES, handler_codes_h
14
14
  from logger_36.instance.logger import LOGGER
15
- from logger_36.task.format.message import FormattedMessage
15
+ from logger_36.task.format.message import MessageWithActualExpected
16
16
 
17
17
 
18
18
  def SetLOGLevel(
@@ -48,7 +48,7 @@ def SetLOGLevel(
48
48
 
49
49
  if not found:
50
50
  raise ValueError(
51
- FormattedMessage(
51
+ MessageWithActualExpected(
52
52
  "Handler not found",
53
53
  actual=which,
54
54
  expected=f"{str(HANDLER_CODES)[1:-1]}, or a handler name",
@@ -4,20 +4,19 @@ Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
4
4
  SEE COPYRIGHT NOTICE BELOW
5
5
  """
6
6
 
7
+ from datetime import timedelta as time_delta_t
8
+
7
9
  LEVEL_OPENING = "("
8
10
  LEVEL_CLOSING = ")"
9
- MESSAGE_MARKER = "| "
11
+ MESSAGE_MARKER = "|"
10
12
  WHERE_SEPARATOR = "@"
11
13
  ELAPSED_TIME_SEPARATOR = "+"
12
- MEMORY_SEPARATOR = ":"
13
14
 
14
15
  DATE_FORMAT = "%Y-%m-%d"
15
16
  TIME_FORMAT = "%H:%M:%S"
16
- WHERE_FORMAT = f" {WHERE_SEPARATOR} {{module}}:{{funcName}}:{{lineno}}"
17
- ELAPSED_TIME_FORMAT = f" {ELAPSED_TIME_SEPARATOR}%(elapsed_time)s"
18
- MEMORY_FORMAT = f" {MEMORY_SEPARATOR}%(memory_usage)s"
17
+ LONG_ENOUGH = time_delta_t(minutes=5)
19
18
 
20
- ACTUAL_PATTERNS: str = r" Actual="
19
+ ACTUAL_PATTERNS: tuple[str] = (r" Actual=",)
21
20
  EXPECTED_PATTERNS: str = r" Expected([!<>]?=|: )"
22
21
 
23
22
  """
@@ -8,8 +8,6 @@ import logging as lggg
8
8
  import re as regx
9
9
  import typing as h
10
10
 
11
- from logger_36.constant.record import HIDE_WHERE_ATTR
12
-
13
11
  LOGGER_NAME = "logger-36"
14
12
 
15
13
  # https://docs.python.org/3/library/logging.html#logging.captureWarnings
@@ -17,8 +15,6 @@ WARNING_LOGGER_NAME = "py.warnings"
17
15
  WARNING_TYPE_PATTERN = r"([^:]+):([0-9]+): ([^:]+): ([^\n]+)\n"
18
16
  WARNING_TYPE_COMPILED_PATTERN = regx.compile(WARNING_TYPE_PATTERN)
19
17
 
20
- HIDE_WHERE_KWARG = {"extra": {HIDE_WHERE_ATTR: True}}
21
-
22
18
  # Second version: with self as first parameter.
23
19
  logger_handle_h = (
24
20
  h.Callable[[lggg.LogRecord], None] | h.Callable[[lggg.Logger, lggg.LogRecord], None]
@@ -8,6 +8,7 @@ import time
8
8
  import typing as h
9
9
 
10
10
  from logger_36.config.message import (
11
+ ELAPSED_TIME_SEPARATOR,
11
12
  LEVEL_CLOSING,
12
13
  LEVEL_OPENING,
13
14
  MESSAGE_MARKER,
@@ -15,9 +16,10 @@ from logger_36.config.message import (
15
16
  )
16
17
 
17
18
  TIME_LENGTH = time.strftime(TIME_FORMAT, time.gmtime(0)).__len__()
19
+ TIME_LENGTH_m_1 = TIME_LENGTH - ELAPSED_TIME_SEPARATOR.__len__()
18
20
  LOG_LEVEL_LENGTH = 1 + LEVEL_OPENING.__len__() + LEVEL_CLOSING.__len__()
19
21
  CONTEXT_LENGTH = TIME_LENGTH + LOG_LEVEL_LENGTH
20
- LINE_INDENT = (CONTEXT_LENGTH + MESSAGE_MARKER.__len__() + 1) * " "
22
+ LINE_INDENT = (CONTEXT_LENGTH + MESSAGE_MARKER.__len__() + 2) * " "
21
23
  NEXT_LINE_PROLOGUE = "\n" + LINE_INDENT
22
24
 
23
25
  expected_op_h = h.Literal[":", ": ", "=", "!=", ">=", "<="]
@@ -4,10 +4,9 @@ Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
4
4
  SEE COPYRIGHT NOTICE BELOW
5
5
  """
6
6
 
7
- SHOW_W_RULE_ATTR = "show_w_rule"
8
- SHOW_WHERE_ATTR = "where"
9
- HIDE_WHERE_ATTR = "hide_where"
10
- SHOW_MEMORY_ATTR = "show_memory_usage"
7
+ SHOW_W_RULE_ATTR = "should_show_w_rule"
8
+ STORE_MEMORY_ATTR = "should_store_memory_usage"
9
+ HIDE_WHERE_ATTR = "should_hide_where"
11
10
 
12
11
  """
13
12
  COPYRIGHT NOTICE
logger_36/content.py CHANGED
@@ -5,7 +5,7 @@ SEE COPYRIGHT NOTICE BELOW
5
5
  """
6
6
 
7
7
  from logger_36.constant.message import LINE_INDENT
8
- from logger_36.task.format.message import FormattedMessage
8
+ from logger_36.task.format.message import MessageWithActualExpected
9
9
  from logger_36.task.format.rule import Rule, RuleAsText
10
10
 
11
11
  """
logger_36/handler.py CHANGED
@@ -33,8 +33,7 @@ def AddGenericHandler(
33
33
  logger: lggg.Logger | None = None,
34
34
  name: str | None = None,
35
35
  level: int = lggg.INFO,
36
- show_where: bool = True,
37
- show_memory_usage: bool = False,
36
+ should_store_memory_usage: bool = False,
38
37
  message_width: int = -1,
39
38
  formatter: lggg.Formatter | None = None,
40
39
  supports_html: bool = False,
@@ -50,8 +49,7 @@ def AddGenericHandler(
50
49
  handler = generic_handler_t(
51
50
  name=name,
52
51
  level=level,
53
- show_where=show_where,
54
- show_memory_usage=show_memory_usage,
52
+ should_store_memory_usage=should_store_memory_usage,
55
53
  message_width=message_width,
56
54
  formatter=formatter,
57
55
  supports_html=supports_html,
@@ -68,8 +66,7 @@ def AddConsoleHandler(
68
66
  logger: lggg.Logger | None = None,
69
67
  name: str | None = None,
70
68
  level: int = lggg.INFO,
71
- show_where: bool = True,
72
- show_memory_usage: bool = False,
69
+ should_store_memory_usage: bool = False,
73
70
  message_width: int = -1,
74
71
  formatter: lggg.Formatter | None = None,
75
72
  should_hold_messages: bool = False,
@@ -81,8 +78,7 @@ def AddConsoleHandler(
81
78
  handler = console_handler_t(
82
79
  name=name,
83
80
  level=level,
84
- show_where=show_where,
85
- show_memory_usage=show_memory_usage,
81
+ should_store_memory_usage=should_store_memory_usage,
86
82
  message_width=message_width,
87
83
  formatter=formatter,
88
84
  )
@@ -94,8 +90,7 @@ def AddRichConsoleHandler(
94
90
  logger: lggg.Logger | None = None,
95
91
  name: str | None = None,
96
92
  level: int = lggg.INFO,
97
- show_where: bool = True,
98
- show_memory_usage: bool = False,
93
+ should_store_memory_usage: bool = False,
99
94
  message_width: int = -1,
100
95
  formatter: lggg.Formatter | None = None,
101
96
  alternating_lines: int = 2,
@@ -125,8 +120,7 @@ def AddRichConsoleHandler(
125
120
  handler = console_rich_handler_t(
126
121
  name=name,
127
122
  level=level,
128
- show_where=show_where,
129
- show_memory_usage=show_memory_usage,
123
+ should_store_memory_usage=should_store_memory_usage,
130
124
  message_width=message_width,
131
125
  formatter=formatter,
132
126
  **additional_s,
@@ -141,8 +135,7 @@ def AddFileHandler(
141
135
  logger: lggg.Logger | None = None,
142
136
  name: str | None = None,
143
137
  level: int = lggg.INFO,
144
- show_where: bool = True,
145
- show_memory_usage: bool = False,
138
+ should_store_memory_usage: bool = False,
146
139
  message_width: int = -1,
147
140
  formatter: lggg.Formatter | None = None,
148
141
  should_hold_messages: bool = False,
@@ -159,8 +152,7 @@ def AddFileHandler(
159
152
  handler = file_handler_t(
160
153
  name=name,
161
154
  level=level,
162
- show_where=show_where,
163
- show_memory_usage=show_memory_usage,
155
+ should_store_memory_usage=should_store_memory_usage,
164
156
  message_width=message_width,
165
157
  formatter=formatter,
166
158
  path=path,
@@ -5,7 +5,7 @@ SEE COPYRIGHT NOTICE BELOW
5
5
  """
6
6
 
7
7
  from logger_36.constant.memory import STORAGE_UNITS, storage_units_h
8
- from logger_36.task.format.message import FormattedMessage
8
+ from logger_36.task.format.message import MessageWithActualExpected
9
9
 
10
10
  _KILO_UNIT = 1000.0
11
11
  _MEGA_UNIT = _KILO_UNIT * 1000.0
@@ -41,7 +41,7 @@ def FormattedUsage(
41
41
  value, unit = FormattedUsageWithAutoUnit(usage, decimals)
42
42
  else:
43
43
  raise ValueError(
44
- FormattedMessage(
44
+ MessageWithActualExpected(
45
45
  "Invalid unit", actual=unit, expected=str(STORAGE_UNITS)[1:-1]
46
46
  )
47
47
  )
@@ -7,35 +7,11 @@ SEE COPYRIGHT NOTICE BELOW
7
7
  import difflib as diff
8
8
  import typing as h
9
9
 
10
- from logger_36.config.message import (
11
- ELAPSED_TIME_FORMAT,
12
- LEVEL_CLOSING,
13
- LEVEL_OPENING,
14
- MEMORY_FORMAT,
15
- MESSAGE_MARKER,
16
- )
17
10
  from logger_36.constant.generic import NOT_PASSED
18
11
  from logger_36.constant.message import expected_op_h
19
12
 
20
13
 
21
- def MessageFormat(with_where: bool, with_memory_usage: bool, /) -> str:
22
- """"""
23
- output = [
24
- f"%(asctime)s"
25
- f"{LEVEL_OPENING}%(level_first_letter)s{LEVEL_CLOSING}\t"
26
- f"{MESSAGE_MARKER}%(message)s"
27
- ]
28
-
29
- if with_where:
30
- output.append("%(where)s")
31
- output.append(ELAPSED_TIME_FORMAT)
32
- if with_memory_usage:
33
- output.append(MEMORY_FORMAT)
34
-
35
- return "".join(output)
36
-
37
-
38
- def FormattedMessage(
14
+ def MessageWithActualExpected(
39
15
  message: str,
40
16
  /,
41
17
  *,