logger-36 2024.12__py3-none-any.whl → 2024.14__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.
- logger_36/catalog/handler/console.py +7 -0
- logger_36/catalog/handler/console_rich.py +7 -0
- logger_36/catalog/handler/file.py +8 -0
- logger_36/catalog/handler/generic.py +3 -0
- logger_36/main.py +8 -0
- logger_36/type/extension.py +49 -2
- logger_36/type/logger.py +10 -4
- logger_36/version.py +1 -1
- {logger_36-2024.12.dist-info → logger_36-2024.14.dist-info}/METADATA +2 -2
- {logger_36-2024.12.dist-info → logger_36-2024.14.dist-info}/RECORD +12 -12
- {logger_36-2024.12.dist-info → logger_36-2024.14.dist-info}/WHEEL +0 -0
- {logger_36-2024.12.dist-info → logger_36-2024.14.dist-info}/top_level.txt +0 -0
@@ -47,6 +47,7 @@ class console_handler_t(lggg.Handler):
|
|
47
47
|
level: dtcl.InitVar[int] = lggg.NOTSET
|
48
48
|
show_where: dtcl.InitVar[bool] = True
|
49
49
|
show_memory_usage: dtcl.InitVar[bool] = False
|
50
|
+
message_width: dtcl.InitVar[int] = -1
|
50
51
|
formatter: dtcl.InitVar[lggg.Formatter | None] = None
|
51
52
|
|
52
53
|
def __post_init__(
|
@@ -55,6 +56,7 @@ class console_handler_t(lggg.Handler):
|
|
55
56
|
level: int,
|
56
57
|
show_where: bool,
|
57
58
|
show_memory_usage: bool,
|
59
|
+
message_width: int,
|
58
60
|
formatter: lggg.Formatter | None,
|
59
61
|
) -> None:
|
60
62
|
""""""
|
@@ -66,6 +68,7 @@ class console_handler_t(lggg.Handler):
|
|
66
68
|
show_memory_usage=show_memory_usage,
|
67
69
|
handler=self,
|
68
70
|
level=level,
|
71
|
+
message_width=message_width,
|
69
72
|
formatter=formatter,
|
70
73
|
)
|
71
74
|
|
@@ -78,3 +81,7 @@ class console_handler_t(lggg.Handler):
|
|
78
81
|
else:
|
79
82
|
message, _ = self.FormattedLines(record, should_join_lines=True)
|
80
83
|
print(message)
|
84
|
+
|
85
|
+
def ShowMessage(self, message: str, /) -> None:
|
86
|
+
""""""
|
87
|
+
print(message)
|
@@ -82,6 +82,7 @@ class console_rich_handler_t(lggg.Handler):
|
|
82
82
|
level: dtcl.InitVar[int] = lggg.NOTSET
|
83
83
|
show_where: dtcl.InitVar[bool] = True
|
84
84
|
show_memory_usage: dtcl.InitVar[bool] = False
|
85
|
+
message_width: dtcl.InitVar[int] = -1
|
85
86
|
formatter: dtcl.InitVar[lggg.Formatter | None] = None
|
86
87
|
should_install_traceback: dtcl.InitVar[bool] = False
|
87
88
|
|
@@ -93,6 +94,7 @@ class console_rich_handler_t(lggg.Handler):
|
|
93
94
|
level: int,
|
94
95
|
show_where: bool,
|
95
96
|
show_memory_usage: bool,
|
97
|
+
message_width: int,
|
96
98
|
formatter: lggg.Formatter | None,
|
97
99
|
should_install_traceback: bool,
|
98
100
|
rich_kwargs: dict[str, h.Any] | None,
|
@@ -106,6 +108,7 @@ class console_rich_handler_t(lggg.Handler):
|
|
106
108
|
show_memory_usage=show_memory_usage,
|
107
109
|
handler=self,
|
108
110
|
level=level,
|
111
|
+
message_width=message_width,
|
109
112
|
formatter=formatter,
|
110
113
|
)
|
111
114
|
|
@@ -144,6 +147,10 @@ class console_rich_handler_t(lggg.Handler):
|
|
144
147
|
richer = cls.HighlightedVersion(first, next_s, record.levelno)
|
145
148
|
self.console.print(richer, crop=False, overflow="ignore")
|
146
149
|
|
150
|
+
def ShowMessage(self, message: str, /) -> None:
|
151
|
+
""""""
|
152
|
+
self.console.print(message, crop=False, overflow="ignore")
|
153
|
+
|
147
154
|
@classmethod
|
148
155
|
def HighlightedVersion(
|
149
156
|
cls, first_line: str, next_lines: str | None, log_level: int, /
|
@@ -49,6 +49,7 @@ class file_handler_t(lggg.FileHandler):
|
|
49
49
|
level: dtcl.InitVar[int] = lggg.NOTSET
|
50
50
|
show_where: dtcl.InitVar[bool] = True
|
51
51
|
show_memory_usage: dtcl.InitVar[bool] = False
|
52
|
+
message_width: dtcl.InitVar[int] = -1
|
52
53
|
formatter: dtcl.InitVar[lggg.Formatter | None] = None
|
53
54
|
|
54
55
|
path: dtcl.InitVar[path_t | None] = None
|
@@ -61,6 +62,7 @@ class file_handler_t(lggg.FileHandler):
|
|
61
62
|
level: int,
|
62
63
|
show_where: bool,
|
63
64
|
show_memory_usage: bool,
|
65
|
+
message_width: int,
|
64
66
|
formatter: lggg.Formatter | None,
|
65
67
|
path: path_t | None,
|
66
68
|
handler_args: tuple[h.Any],
|
@@ -75,6 +77,7 @@ class file_handler_t(lggg.FileHandler):
|
|
75
77
|
show_memory_usage=show_memory_usage,
|
76
78
|
handler=self,
|
77
79
|
level=level,
|
80
|
+
message_width=message_width,
|
78
81
|
formatter=formatter,
|
79
82
|
)
|
80
83
|
|
@@ -88,3 +91,8 @@ class file_handler_t(lggg.FileHandler):
|
|
88
91
|
message, _ = self.FormattedLines(record, should_join_lines=True)
|
89
92
|
print(message, file=self.stream)
|
90
93
|
self.stream.flush()
|
94
|
+
|
95
|
+
def ShowMessage(self, message: str, /) -> None:
|
96
|
+
""""""
|
97
|
+
print(message, file=self.stream)
|
98
|
+
self.stream.flush()
|
@@ -69,6 +69,7 @@ class generic_handler_t(lggg.Handler):
|
|
69
69
|
level: dtcl.InitVar[int] = lggg.NOTSET
|
70
70
|
show_where: dtcl.InitVar[bool] = True
|
71
71
|
show_memory_usage: dtcl.InitVar[bool] = False
|
72
|
+
message_width: dtcl.InitVar[int] = -1
|
72
73
|
formatter: dtcl.InitVar[lggg.Formatter | None] = None
|
73
74
|
|
74
75
|
supports_html: dtcl.InitVar[bool] = False
|
@@ -81,6 +82,7 @@ class generic_handler_t(lggg.Handler):
|
|
81
82
|
level: int,
|
82
83
|
show_where: bool,
|
83
84
|
show_memory_usage: bool,
|
85
|
+
message_width: int,
|
84
86
|
formatter: lggg.Formatter | None,
|
85
87
|
supports_html: bool,
|
86
88
|
rich_kwargs: dict[str, h.Any] | None,
|
@@ -95,6 +97,7 @@ class generic_handler_t(lggg.Handler):
|
|
95
97
|
show_memory_usage=show_memory_usage,
|
96
98
|
handler=self,
|
97
99
|
level=level,
|
100
|
+
message_width=message_width,
|
98
101
|
formatter=formatter,
|
99
102
|
)
|
100
103
|
|
logger_36/main.py
CHANGED
@@ -62,6 +62,7 @@ def AddGenericHandler(
|
|
62
62
|
level: int = lggg.INFO,
|
63
63
|
show_where: bool = True,
|
64
64
|
show_memory_usage: bool = False,
|
65
|
+
message_width: int = -1,
|
65
66
|
formatter: lggg.Formatter | None = None,
|
66
67
|
supports_html: bool = False,
|
67
68
|
should_hold_messages: bool = False,
|
@@ -76,6 +77,7 @@ def AddGenericHandler(
|
|
76
77
|
level=level,
|
77
78
|
show_where=show_where,
|
78
79
|
show_memory_usage=show_memory_usage,
|
80
|
+
message_width=message_width,
|
79
81
|
formatter=formatter,
|
80
82
|
supports_html=supports_html,
|
81
83
|
rich_kwargs=kwargs,
|
@@ -91,6 +93,7 @@ def AddConsoleHandler(
|
|
91
93
|
level: int = lggg.INFO,
|
92
94
|
show_where: bool = True,
|
93
95
|
show_memory_usage: bool = False,
|
96
|
+
message_width: int = -1,
|
94
97
|
formatter: lggg.Formatter | None = None,
|
95
98
|
should_hold_messages: bool = False,
|
96
99
|
) -> None:
|
@@ -103,6 +106,7 @@ def AddConsoleHandler(
|
|
103
106
|
level=level,
|
104
107
|
show_where=show_where,
|
105
108
|
show_memory_usage=show_memory_usage,
|
109
|
+
message_width=message_width,
|
106
110
|
formatter=formatter,
|
107
111
|
)
|
108
112
|
logger.AddHandler(handler, should_hold_messages)
|
@@ -115,6 +119,7 @@ def AddRichConsoleHandler(
|
|
115
119
|
level: int = lggg.INFO,
|
116
120
|
show_where: bool = True,
|
117
121
|
show_memory_usage: bool = False,
|
122
|
+
message_width: int = -1,
|
118
123
|
formatter: lggg.Formatter | None = None,
|
119
124
|
should_hold_messages: bool = False,
|
120
125
|
should_install_traceback: bool = False,
|
@@ -134,6 +139,7 @@ def AddRichConsoleHandler(
|
|
134
139
|
level=level,
|
135
140
|
show_where=show_where,
|
136
141
|
show_memory_usage=show_memory_usage,
|
142
|
+
message_width=message_width,
|
137
143
|
formatter=formatter,
|
138
144
|
should_install_traceback=should_install_traceback,
|
139
145
|
rich_kwargs=kwargs,
|
@@ -150,6 +156,7 @@ def AddFileHandler(
|
|
150
156
|
level: int = lggg.INFO,
|
151
157
|
show_where: bool = True,
|
152
158
|
show_memory_usage: bool = False,
|
159
|
+
message_width: int = -1,
|
153
160
|
formatter: lggg.Formatter | None = None,
|
154
161
|
should_hold_messages: bool = False,
|
155
162
|
**kwargs,
|
@@ -167,6 +174,7 @@ def AddFileHandler(
|
|
167
174
|
level=level,
|
168
175
|
show_where=show_where,
|
169
176
|
show_memory_usage=show_memory_usage,
|
177
|
+
message_width=message_width,
|
170
178
|
formatter=formatter,
|
171
179
|
path=path,
|
172
180
|
handler_args=args,
|
logger_36/type/extension.py
CHANGED
@@ -53,6 +53,7 @@ class handler_extension_t:
|
|
53
53
|
name: str | None = None
|
54
54
|
show_where: bool = True
|
55
55
|
show_memory_usage: bool = False
|
56
|
+
message_width: int = -1
|
56
57
|
FormattedRecord: h.Callable[[lggg.LogRecord], str] = dtcl.field(init=False)
|
57
58
|
|
58
59
|
handler: dtcl.InitVar[lggg.Handler | None] = None
|
@@ -85,6 +86,8 @@ class handler_extension_t:
|
|
85
86
|
|
86
87
|
handler.setLevel(level)
|
87
88
|
|
89
|
+
if 0 < self.message_width < 5:
|
90
|
+
self.message_width = 5
|
88
91
|
if formatter is None:
|
89
92
|
message_format = MessageFormat(self.show_where, self.show_memory_usage)
|
90
93
|
formatter = lggg.Formatter(fmt=message_format, datefmt=TIME_FORMAT)
|
@@ -111,13 +114,26 @@ class handler_extension_t:
|
|
111
114
|
|
112
115
|
if PreProcessed is not None:
|
113
116
|
message = PreProcessed(message)
|
114
|
-
if "\n" in message
|
115
|
-
|
117
|
+
if (has_newlines := ("\n" in message)) or (
|
118
|
+
(self.message_width > 0) and (message.__len__() > self.message_width)
|
119
|
+
):
|
120
|
+
if has_newlines:
|
121
|
+
lines = message.splitlines()
|
122
|
+
if self.message_width > 0:
|
123
|
+
lines = _WrappedLines(lines, self.message_width)
|
124
|
+
else:
|
125
|
+
lines = _WrappedLines([message], self.message_width)
|
116
126
|
next_lines = NEXT_LINE_PROLOGUE.join(lines[1:])
|
117
127
|
next_lines = f"{NEXT_LINE_PROLOGUE}{next_lines}"
|
118
128
|
message = lines[0]
|
119
129
|
else:
|
120
130
|
next_lines = None
|
131
|
+
if self.message_width > 0:
|
132
|
+
n_missing_s = self.message_width - message.__len__()
|
133
|
+
if n_missing_s > 3:
|
134
|
+
message += " " + (n_missing_s - 1) * "."
|
135
|
+
elif n_missing_s > 0:
|
136
|
+
message += n_missing_s * " "
|
121
137
|
|
122
138
|
record.msg = message
|
123
139
|
if self.show_where and not hasattr(record, SHOW_WHERE_ATTR):
|
@@ -152,3 +168,34 @@ class handler_extension_t:
|
|
152
168
|
return f"{first_line}{next_lines}", None
|
153
169
|
else:
|
154
170
|
return first_line, next_lines
|
171
|
+
|
172
|
+
|
173
|
+
def _WrappedLines(lines: list[str], message_width: int, /) -> list[str]:
|
174
|
+
""""""
|
175
|
+
output = []
|
176
|
+
|
177
|
+
for line in lines:
|
178
|
+
while line.__len__() > message_width:
|
179
|
+
if all(
|
180
|
+
_elm != " " for _elm in line[(message_width - 1) : (message_width + 1)]
|
181
|
+
):
|
182
|
+
if line[message_width - 2] == " ":
|
183
|
+
piece, line = (
|
184
|
+
line[: (message_width - 2)].rstrip(),
|
185
|
+
line[(message_width - 1) :],
|
186
|
+
)
|
187
|
+
else:
|
188
|
+
piece, line = (
|
189
|
+
line[: (message_width - 1)] + "-",
|
190
|
+
line[(message_width - 1) :],
|
191
|
+
)
|
192
|
+
else:
|
193
|
+
piece, line = (
|
194
|
+
line[:message_width].rstrip(),
|
195
|
+
line[message_width:].lstrip(),
|
196
|
+
)
|
197
|
+
output.append(piece)
|
198
|
+
|
199
|
+
output.append(line)
|
200
|
+
|
201
|
+
return output
|
logger_36/type/logger.py
CHANGED
@@ -65,13 +65,12 @@ from logger_36.type.issue import NewIssue, issue_t
|
|
65
65
|
|
66
66
|
@dtcl.dataclass(slots=True, repr=False, eq=False)
|
67
67
|
class logger_t(lggg.Logger):
|
68
|
-
# Must not be False until at least one handler has been added.
|
69
|
-
should_hold_messages: bool = True
|
70
|
-
|
71
68
|
name: dtcl.InitVar[str] = LOGGER_NAME
|
72
69
|
level: dtcl.InitVar[int] = lggg.NOTSET
|
73
70
|
activate_wrn_interceptions: dtcl.InitVar[bool] = True
|
74
71
|
exit_on_error: bool = False
|
72
|
+
# Must not be False until at least one handler has been added.
|
73
|
+
should_hold_messages: bool = True
|
75
74
|
|
76
75
|
on_hold: list[lggg.LogRecord] = dtcl.field(init=False, default_factory=list)
|
77
76
|
last_message_date: str = dtcl.field(init=False, default="")
|
@@ -221,7 +220,7 @@ class logger_t(lggg.Logger):
|
|
221
220
|
date = dttm.now().strftime(DATE_FORMAT)
|
222
221
|
if date != self.last_message_date:
|
223
222
|
self.last_message_date = date
|
224
|
-
# levelno: Added for management by
|
223
|
+
# levelno: Added for management by logging.Logger.handle.
|
225
224
|
date_record = lggg.makeLogRecord(
|
226
225
|
{
|
227
226
|
"name": self.name,
|
@@ -317,6 +316,13 @@ class logger_t(lggg.Logger):
|
|
317
316
|
self.log(level, issues, stacklevel=2)
|
318
317
|
self.staged_issues.clear()
|
319
318
|
|
319
|
+
def ShowMessage(self, message: str, /) -> None:
|
320
|
+
""""""
|
321
|
+
for handler in self.handlers:
|
322
|
+
ShowMessage = getattr(handler, "ShowMessage", None)
|
323
|
+
if ShowMessage is not None:
|
324
|
+
ShowMessage(message)
|
325
|
+
|
320
326
|
def __enter__(self) -> None:
|
321
327
|
""""""
|
322
328
|
pass
|
logger_36/version.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: logger-36
|
3
|
-
Version: 2024.
|
3
|
+
Version: 2024.14
|
4
4
|
Summary: Simple logger with a catalog of handlers
|
5
5
|
Home-page: https://src.koda.cnrs.fr/eric.debreuve/logger-36/
|
6
6
|
Author: Eric Debreuve
|
@@ -104,7 +104,7 @@ The development relies on several packages:
|
|
104
104
|
- Mandatory: |DEPENDENCIES_MANDATORY|
|
105
105
|
- Optional: |DEPENDENCIES_OPTIONAL|
|
106
106
|
|
107
|
-
The mandatory dependencies are installed automatically by `pip <https://pip.pypa.io/>`_, if they are not already, as part of the installation of |PROJECT_NAME|.
|
107
|
+
The mandatory dependencies, if any, are installed automatically by `pip <https://pip.pypa.io/>`_, if they are not already, as part of the installation of |PROJECT_NAME|.
|
108
108
|
Python distribution platforms or Integrated Development Environments (IDEs) should also take care of this.
|
109
109
|
The optional dependencies, if any, must be installed independently by following the related instructions, for added functionalities of |PROJECT_NAME|.
|
110
110
|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
logger_36/__init__.py,sha256=67ZAWtUx9Qy8Yn-tLQkOIEO6Z9U-8jhfm-tqNjjeFPU,1758
|
2
2
|
logger_36/instance.py,sha256=wAVty29f24SCs4FRL600QySlA_WeLUM78p4t_Ni-LzA,1618
|
3
|
-
logger_36/main.py,sha256=
|
4
|
-
logger_36/version.py,sha256=
|
3
|
+
logger_36/main.py,sha256=H0MW3hZXdXHjTnliH8GNJkjqPZITLTaeaNH7lZPPFFI,6822
|
4
|
+
logger_36/version.py,sha256=_w8Z7Tt2m9tTPumKTtoVeoqwwUApzfXyHi6l50AyZu8,1578
|
5
5
|
logger_36/catalog/config/console_rich.py,sha256=XKRKJx_5dxp4mgan1D-u_qrQos-pezRccqKsnmn-ook,2119
|
6
|
-
logger_36/catalog/handler/console.py,sha256=
|
7
|
-
logger_36/catalog/handler/console_rich.py,sha256=
|
8
|
-
logger_36/catalog/handler/file.py,sha256=
|
9
|
-
logger_36/catalog/handler/generic.py,sha256=
|
6
|
+
logger_36/catalog/handler/console.py,sha256=QaSxXmBYp1rVRu7lj17KPQiDyLOgb6GLmh3orIx9mv0,3296
|
7
|
+
logger_36/catalog/handler/console_rich.py,sha256=k8aTPBtIrL8tjIYhN4F2rGCPB2t8f1fWwFHhn33y2gs,6759
|
8
|
+
logger_36/catalog/handler/file.py,sha256=K1bIS8fAT1aOWllWNag9mSabairxRfgZSGKub9dl8cE,3757
|
9
|
+
logger_36/catalog/handler/generic.py,sha256=xpFnMuG3d9Xr2i5Tu_y8pU2Ohuu6CeZ4oGg5xyHmTtQ,6435
|
10
10
|
logger_36/catalog/logging/chronos.py,sha256=zVe5ZwB63mqNqlIDm6ZBi4-U5n_n-21h8umhimRUcdU,1815
|
11
11
|
logger_36/catalog/logging/gpu.py,sha256=0XqVVK_TV1QPEwGXyK99jThHAjfsf-V__3m9Jh4gewk,2783
|
12
12
|
logger_36/catalog/logging/memory.py,sha256=-5SOXAV43RnXznBPbClVMpMqtMlVtBsI46w6ngz1oP4,4040
|
@@ -31,10 +31,10 @@ logger_36/task/format/message.py,sha256=91CCgH7umLHUV_YRf4AyOsYZTgNVOvQSODqXO1wJ
|
|
31
31
|
logger_36/task/format/rule.py,sha256=cq4jl_ZCb8m7QoX8mWevXhy1hgwncLpc-9woKoT7m24,1970
|
32
32
|
logger_36/task/measure/chronos.py,sha256=7xZskYEXQCPDypmnlhn4KDCBB1v3eL1OE_sv-l3n8Do,2255
|
33
33
|
logger_36/task/measure/memory.py,sha256=aichGI-iCeE3Z4Y8AmWGdal2931IMdcdv4VgCeDLBoI,1876
|
34
|
-
logger_36/type/extension.py,sha256=
|
34
|
+
logger_36/type/extension.py,sha256=U28VqEL3Wq_E_TZ-ZlBAXRyTr9oVPnA6ez7EyHjKM0E,7673
|
35
35
|
logger_36/type/issue.py,sha256=OnkBKRTMsHvZ-2aLQWtBzGSWMTVs_4ermg71Ygcs0w8,2153
|
36
|
-
logger_36/type/logger.py,sha256=
|
37
|
-
logger_36-2024.
|
38
|
-
logger_36-2024.
|
39
|
-
logger_36-2024.
|
40
|
-
logger_36-2024.
|
36
|
+
logger_36/type/logger.py,sha256=SNBFJ1PSSKSDC-yWaP1cgUKf2qmY7-orkkH0HOKwJgY,13446
|
37
|
+
logger_36-2024.14.dist-info/METADATA,sha256=zCImQdXhsHf2P4tV9JMjJJ2xxrN-UdTi-5psLiweHd4,5601
|
38
|
+
logger_36-2024.14.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
39
|
+
logger_36-2024.14.dist-info/top_level.txt,sha256=sM95BTMWmslEEgR_1pzwZsOeSp8C_QBiu8ImbFr0XLc,10
|
40
|
+
logger_36-2024.14.dist-info/RECORD,,
|
File without changes
|
File without changes
|