logger-36 2024.4__py3-none-any.whl → 2024.5__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/main.py +30 -6
- logger_36/type/logger.py +7 -8
- logger_36/version.py +1 -1
- {logger_36-2024.4.dist-info → logger_36-2024.5.dist-info}/METADATA +3 -3
- {logger_36-2024.4.dist-info → logger_36-2024.5.dist-info}/RECORD +7 -7
- {logger_36-2024.4.dist-info → logger_36-2024.5.dist-info}/WHEEL +0 -0
- {logger_36-2024.4.dist-info → logger_36-2024.5.dist-info}/top_level.txt +0 -0
logger_36/main.py
CHANGED
@@ -61,6 +61,7 @@ def AddGenericHandler(
|
|
61
61
|
interface: interface_h,
|
62
62
|
/,
|
63
63
|
*,
|
64
|
+
logger: lggg.Logger | None = None,
|
64
65
|
name: str | None = None,
|
65
66
|
level: int = lggg.INFO,
|
66
67
|
show_where: bool = True,
|
@@ -71,6 +72,9 @@ def AddGenericHandler(
|
|
71
72
|
**kwargs,
|
72
73
|
) -> None:
|
73
74
|
""""""
|
75
|
+
if logger is None:
|
76
|
+
logger = LOGGER
|
77
|
+
|
74
78
|
handler = generic_handler_t(
|
75
79
|
name=name,
|
76
80
|
level=level,
|
@@ -81,11 +85,12 @@ def AddGenericHandler(
|
|
81
85
|
rich_kwargs=kwargs,
|
82
86
|
interface=interface,
|
83
87
|
)
|
84
|
-
|
88
|
+
logger.AddHandler(handler, should_hold_messages)
|
85
89
|
|
86
90
|
|
87
91
|
def AddConsoleHandler(
|
88
92
|
*,
|
93
|
+
logger: lggg.Logger | None = None,
|
89
94
|
name: str | None = None,
|
90
95
|
level: int = lggg.INFO,
|
91
96
|
show_where: bool = True,
|
@@ -94,6 +99,9 @@ def AddConsoleHandler(
|
|
94
99
|
should_hold_messages: bool = False,
|
95
100
|
) -> None:
|
96
101
|
""""""
|
102
|
+
if logger is None:
|
103
|
+
logger = LOGGER
|
104
|
+
|
97
105
|
handler = console_handler_t(
|
98
106
|
name=name,
|
99
107
|
level=level,
|
@@ -101,11 +109,12 @@ def AddConsoleHandler(
|
|
101
109
|
show_memory_usage=show_memory_usage,
|
102
110
|
formatter=formatter,
|
103
111
|
)
|
104
|
-
|
112
|
+
logger.AddHandler(handler, should_hold_messages)
|
105
113
|
|
106
114
|
|
107
115
|
def AddRichConsoleHandler(
|
108
116
|
*,
|
117
|
+
logger: lggg.Logger | None = None,
|
109
118
|
name: str | None = None,
|
110
119
|
level: int = lggg.INFO,
|
111
120
|
show_where: bool = True,
|
@@ -120,6 +129,9 @@ def AddRichConsoleHandler(
|
|
120
129
|
print(_RICH_ERROR, file=sstm.stderr)
|
121
130
|
_RICH_ERROR = None
|
122
131
|
|
132
|
+
if logger is None:
|
133
|
+
logger = LOGGER
|
134
|
+
|
123
135
|
handler = console_rich_handler_t(
|
124
136
|
name=name,
|
125
137
|
level=level,
|
@@ -128,13 +140,14 @@ def AddRichConsoleHandler(
|
|
128
140
|
formatter=formatter,
|
129
141
|
rich_kwargs=kwargs,
|
130
142
|
)
|
131
|
-
|
143
|
+
logger.AddHandler(handler, should_hold_messages)
|
132
144
|
|
133
145
|
|
134
146
|
def AddFileHandler(
|
135
147
|
path: str | path_t,
|
136
148
|
/,
|
137
149
|
*args,
|
150
|
+
logger: lggg.Logger | None = None,
|
138
151
|
name: str | None = None,
|
139
152
|
level: int = lggg.INFO,
|
140
153
|
show_where: bool = True,
|
@@ -148,6 +161,8 @@ def AddFileHandler(
|
|
148
161
|
path = path_t(path)
|
149
162
|
if path.exists():
|
150
163
|
raise ValueError(f"File or folder already exists: {path}.")
|
164
|
+
if logger is None:
|
165
|
+
logger = LOGGER
|
151
166
|
|
152
167
|
handler = file_handler_t(
|
153
168
|
name=name,
|
@@ -159,16 +174,25 @@ def AddFileHandler(
|
|
159
174
|
handler_args=args,
|
160
175
|
handler_kwargs=kwargs,
|
161
176
|
)
|
162
|
-
|
177
|
+
logger.AddHandler(handler, should_hold_messages)
|
163
178
|
|
164
179
|
|
165
|
-
def SetLOGLevel(
|
180
|
+
def SetLOGLevel(
|
181
|
+
level: int,
|
182
|
+
/,
|
183
|
+
*,
|
184
|
+
logger: lggg.Logger | None = None,
|
185
|
+
which: handler_codes_h | str = "a",
|
186
|
+
) -> None:
|
166
187
|
"""
|
167
188
|
which: g=generic, c=console, f=file, a=all, str=name.
|
168
189
|
"""
|
190
|
+
if logger is None:
|
191
|
+
logger = LOGGER
|
192
|
+
|
169
193
|
which_is_name = which not in HANDLER_CODES
|
170
194
|
found = False
|
171
|
-
for handler in
|
195
|
+
for handler in logger.handlers:
|
172
196
|
if (
|
173
197
|
(which == "a")
|
174
198
|
or ((which == "g") and isinstance(handler, generic_handler_t))
|
logger_36/type/logger.py
CHANGED
@@ -296,17 +296,16 @@ class logger_t(lggg.Logger):
|
|
296
296
|
issues = sorted(self.staged_issues, key=lambda _elm: _elm.context)
|
297
297
|
issues = "\n".join(issues)
|
298
298
|
|
299
|
-
if issubclass(level, Exception):
|
299
|
+
if isinstance(level, type) and issubclass(level, Exception):
|
300
300
|
try:
|
301
301
|
raise level("\n" + issues)
|
302
302
|
except Exception as exception:
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
)
|
303
|
+
lines = ["Traceback (most recent call last):"] + tbck.format_stack()[
|
304
|
+
:-1
|
305
|
+
]
|
306
|
+
lines[-1] = lines[-1][:-1]
|
307
|
+
lines.extend(tbck.format_exception_only(exception))
|
308
|
+
print("\n".join(lines), file=sstm.stderr)
|
310
309
|
sstm.exit(1)
|
311
310
|
|
312
311
|
self.log(level, issues, **HIDE_WHERE_KWARG)
|
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.5
|
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
|
@@ -12,8 +12,8 @@ Keywords: log,warning,error
|
|
12
12
|
Classifier: Topic :: Software Development
|
13
13
|
Classifier: Intended Audience :: Developers
|
14
14
|
Classifier: License :: OSI Approved :: CEA CNRS Inria Logiciel Libre License, version 2.1 (CeCILL-2.1)
|
15
|
-
Classifier: Programming Language :: Python :: 3
|
16
|
-
Classifier: Development Status ::
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
16
|
+
Classifier: Development Status :: 5 - Production/Stable
|
17
17
|
Requires-Python: >=3.10
|
18
18
|
Description-Content-Type: text/x-rst
|
19
19
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
logger_36/__init__.py,sha256=-VGyte6TD6SWU4jBXUjur_xU1R1Asha5KXEwDNmGJ6Q,1756
|
2
2
|
logger_36/instance.py,sha256=NQlDAyXV3TNekX9xj9V7JMePmsa2DWnTDaVzh5dcyGM,1616
|
3
|
-
logger_36/main.py,sha256=
|
4
|
-
logger_36/version.py,sha256=
|
3
|
+
logger_36/main.py,sha256=tN2GD-tL5UcRwW1HuJHcIh8WlLBbXO-zF-6Sy700Uwo,6587
|
4
|
+
logger_36/version.py,sha256=U3BX6By9kxj1MIlg-OiskCuwp9JDaGz-_Skvedwbjzo,1575
|
5
5
|
logger_36/catalog/config/console_rich.py,sha256=jJnYXPDsMCTu8zny2X3NdeyKFCfhJupberqIBxyv3LA,2030
|
6
6
|
logger_36/catalog/handler/console.py,sha256=PnaCWJsXN-x_-X8i-4o4HWys-7K0A83s4kIdtmDz3AQ,3092
|
7
7
|
logger_36/catalog/handler/console_rich.py,sha256=YqKyKwHoYCEVnW1S87NDu3ReTCIzSdYgC-20-813TFQ,5395
|
@@ -32,8 +32,8 @@ logger_36/task/measure/chronos.py,sha256=qT80jxZm_dAg2P4WkfU0L3PRvRojT21Ps3DtNYq
|
|
32
32
|
logger_36/task/measure/memory.py,sha256=1f1X-XHd_58LJYJ0Ok5TGIagnf0k5F39IFqWHN2Ojas,1874
|
33
33
|
logger_36/type/extension.py,sha256=fsYx0wT1bR6DtpM2VnaxsM0MFv2vBLROgRSCs4duasY,5198
|
34
34
|
logger_36/type/issue.py,sha256=T1WFtc8Js1OChYkIHQiOP825Dcb9atpEprLWaPTxAHA,2151
|
35
|
-
logger_36/type/logger.py,sha256=
|
36
|
-
logger_36-2024.
|
37
|
-
logger_36-2024.
|
38
|
-
logger_36-2024.
|
39
|
-
logger_36-2024.
|
35
|
+
logger_36/type/logger.py,sha256=t1pXc82F8wF-g-qyh7VxyoFBp0MKgtpOoyDznem9L6Q,12729
|
36
|
+
logger_36-2024.5.dist-info/METADATA,sha256=fD1AEJe7mGRC55VHNLcGGJ2c51Igp_0hq0F1PvMveiQ,4246
|
37
|
+
logger_36-2024.5.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
38
|
+
logger_36-2024.5.dist-info/top_level.txt,sha256=sM95BTMWmslEEgR_1pzwZsOeSp8C_QBiu8ImbFr0XLc,10
|
39
|
+
logger_36-2024.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|