omlish 0.0.0.dev424__py3-none-any.whl → 0.0.0.dev425__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.
- omlish/__about__.py +3 -3
- omlish/dataclasses/impl/configs.py +2 -1
- omlish/formats/json/stream/lexing.py +8 -0
- omlish/formats/json/stream/utils.py +3 -0
- omlish/formats/json5/streams.py +22 -0
- omlish/lang/__init__.py +3 -1
- omlish/lang/asyncs.py +12 -0
- omlish/lang/functions.py +0 -11
- omlish/lang/lazyglobals.py +27 -5
- omlish/lang/maysync.py +2 -2
- omlish/lifecycles/contextmanagers.py +1 -2
- omlish/lifecycles/controller.py +1 -2
- omlish/lite/asyncs.py +15 -0
- omlish/lite/timing.py +2 -2
- omlish/logs/all.py +23 -34
- omlish/logs/base.py +248 -0
- omlish/logs/callers.py +21 -15
- omlish/logs/infos.py +105 -0
- omlish/logs/levels.py +64 -0
- omlish/logs/protocols.py +31 -0
- omlish/logs/standard.py +12 -11
- omlish/logs/std/adapters.py +41 -0
- omlish/logs/std/configs.py +29 -0
- omlish/logs/{filters.py → std/filters.py} +1 -1
- omlish/logs/{handlers.py → std/handlers.py} +1 -1
- omlish/logs/{json.py → std/json.py} +2 -2
- omlish/logs/{proxy.py → std/proxy.py} +3 -3
- omlish/logs/std/records.py +286 -0
- omlish/logs/times.py +89 -0
- omlish/logs/typed/bindings.py +24 -0
- omlish/logs/utils.py +60 -4
- omlish/logs/warnings.py +8 -0
- omlish/manifests/loading.py +1 -1
- omlish/os/journald.py +3 -3
- omlish/testing/pytest/plugins/skips.py +0 -4
- {omlish-0.0.0.dev424.dist-info → omlish-0.0.0.dev425.dist-info}/METADATA +1 -1
- {omlish-0.0.0.dev424.dist-info → omlish-0.0.0.dev425.dist-info}/RECORD +44 -86
- omlish/defs.py +0 -216
- omlish/dispatch/_dispatch2.py +0 -69
- omlish/dispatch/_dispatch3.py +0 -108
- omlish/dynamic.py +0 -219
- omlish/formats/json/Json.g4 +0 -77
- omlish/formats/json/_antlr/JsonLexer.py +0 -109
- omlish/formats/json/_antlr/JsonListener.py +0 -61
- omlish/formats/json/_antlr/JsonParser.py +0 -457
- omlish/formats/json/_antlr/JsonVisitor.py +0 -42
- omlish/io/trampoline.py +0 -289
- omlish/logs/abc.py +0 -319
- omlish/logs/color.py +0 -27
- omlish/logs/configs.py +0 -29
- omlish/logs/protocol.py +0 -218
- omlish/logs/timing.py +0 -58
- omlish/specs/irc/__init__.py +0 -0
- omlish/specs/irc/messages/__init__.py +0 -0
- omlish/specs/irc/messages/base.py +0 -49
- omlish/specs/irc/messages/formats.py +0 -92
- omlish/specs/irc/messages/messages.py +0 -774
- omlish/specs/irc/messages/parsing.py +0 -98
- omlish/specs/irc/numerics/__init__.py +0 -0
- omlish/specs/irc/numerics/formats.py +0 -97
- omlish/specs/irc/numerics/numerics.py +0 -865
- omlish/specs/irc/numerics/types.py +0 -59
- omlish/specs/irc/protocol/LICENSE +0 -11
- omlish/specs/irc/protocol/__init__.py +0 -61
- omlish/specs/irc/protocol/consts.py +0 -6
- omlish/specs/irc/protocol/errors.py +0 -30
- omlish/specs/irc/protocol/message.py +0 -21
- omlish/specs/irc/protocol/nuh.py +0 -55
- omlish/specs/irc/protocol/parsing.py +0 -158
- omlish/specs/irc/protocol/rendering.py +0 -153
- omlish/specs/irc/protocol/tags.py +0 -102
- omlish/specs/irc/protocol/utils.py +0 -30
- omlish/specs/proto/Protobuf3.g4 +0 -396
- omlish/specs/proto/__init__.py +0 -0
- omlish/specs/proto/_antlr/Protobuf3Lexer.py +0 -340
- omlish/specs/proto/_antlr/Protobuf3Listener.py +0 -448
- omlish/specs/proto/_antlr/Protobuf3Parser.py +0 -3909
- omlish/specs/proto/_antlr/Protobuf3Visitor.py +0 -257
- omlish/specs/proto/_antlr/__init__.py +0 -0
- omlish/specs/proto/nodes.py +0 -54
- omlish/specs/proto/parsing.py +0 -97
- omlish/sql/parsing/Minisql.g4 +0 -292
- omlish/sql/parsing/__init__.py +0 -0
- omlish/sql/parsing/_antlr/MinisqlLexer.py +0 -322
- omlish/sql/parsing/_antlr/MinisqlListener.py +0 -511
- omlish/sql/parsing/_antlr/MinisqlParser.py +0 -3763
- omlish/sql/parsing/_antlr/MinisqlVisitor.py +0 -292
- omlish/sql/parsing/_antlr/__init__.py +0 -0
- omlish/sql/parsing/parsing.py +0 -119
- /omlish/{.manifests.json → .omlish-manifests.json} +0 -0
- /omlish/{formats/json/_antlr → logs/std}/__init__.py +0 -0
- /omlish/logs/{noisy.py → std/noisy.py} +0 -0
- {omlish-0.0.0.dev424.dist-info → omlish-0.0.0.dev425.dist-info}/WHEEL +0 -0
- {omlish-0.0.0.dev424.dist-info → omlish-0.0.0.dev425.dist-info}/entry_points.txt +0 -0
- {omlish-0.0.0.dev424.dist-info → omlish-0.0.0.dev425.dist-info}/licenses/LICENSE +0 -0
- {omlish-0.0.0.dev424.dist-info → omlish-0.0.0.dev425.dist-info}/top_level.txt +0 -0
omlish/io/trampoline.py
DELETED
@@ -1,289 +0,0 @@
|
|
1
|
-
import abc
|
2
|
-
import contextlib
|
3
|
-
import io
|
4
|
-
import typing as ta
|
5
|
-
|
6
|
-
from .. import check
|
7
|
-
from .. import lang
|
8
|
-
from ..concurrent import threadlets as tls
|
9
|
-
from ..sync import ConditionDeque
|
10
|
-
|
11
|
-
|
12
|
-
if ta.TYPE_CHECKING:
|
13
|
-
import threading
|
14
|
-
|
15
|
-
from . import pyio # noqa
|
16
|
-
|
17
|
-
else:
|
18
|
-
threading = lang.proxy_import('threading')
|
19
|
-
|
20
|
-
pyio = lang.proxy_import('.pyio', __package__)
|
21
|
-
|
22
|
-
|
23
|
-
T = ta.TypeVar('T')
|
24
|
-
|
25
|
-
BytesLike: ta.TypeAlias = ta.Any
|
26
|
-
|
27
|
-
BufferedReader: ta.TypeAlias = io.BufferedReader
|
28
|
-
# BufferedReader: ta.TypeAlias = pyio.BufferedReader
|
29
|
-
|
30
|
-
|
31
|
-
##
|
32
|
-
|
33
|
-
|
34
|
-
class ProxyReadFile:
|
35
|
-
def __init__(self, read: ta.Callable[[int], bytes | BaseException]) -> None:
|
36
|
-
super().__init__()
|
37
|
-
|
38
|
-
self._read = read
|
39
|
-
self._eof = False
|
40
|
-
self._closed = False
|
41
|
-
|
42
|
-
#
|
43
|
-
|
44
|
-
def read(self, n: int, /) -> bytes:
|
45
|
-
if self._closed:
|
46
|
-
raise RuntimeError('Closed')
|
47
|
-
if self._eof:
|
48
|
-
return b''
|
49
|
-
d = self._read(n)
|
50
|
-
if isinstance(d, BaseException):
|
51
|
-
raise d
|
52
|
-
if not d:
|
53
|
-
self._eof = True
|
54
|
-
return d
|
55
|
-
|
56
|
-
def readall(self, *args, **kwargs):
|
57
|
-
raise TypeError # FIXME
|
58
|
-
|
59
|
-
def readinto(self, b: BytesLike) -> int | None:
|
60
|
-
d = self.read(len(b))
|
61
|
-
if d:
|
62
|
-
b[:len(d)] = d
|
63
|
-
return len(d)
|
64
|
-
|
65
|
-
#
|
66
|
-
|
67
|
-
def readable(self) -> bool:
|
68
|
-
return not (self._eof or self._closed)
|
69
|
-
|
70
|
-
@property
|
71
|
-
def closed(self) -> bool:
|
72
|
-
return self._closed
|
73
|
-
|
74
|
-
def close(self) -> None:
|
75
|
-
self._closed = True
|
76
|
-
|
77
|
-
#
|
78
|
-
|
79
|
-
def flush(self) -> None:
|
80
|
-
pass
|
81
|
-
|
82
|
-
def seekable(self) -> bool:
|
83
|
-
return False
|
84
|
-
|
85
|
-
def seek(self, n: int, /) -> ta.Any:
|
86
|
-
raise TypeError
|
87
|
-
|
88
|
-
|
89
|
-
##
|
90
|
-
|
91
|
-
|
92
|
-
class NeedMore(lang.Marker):
|
93
|
-
pass
|
94
|
-
|
95
|
-
|
96
|
-
class Exited(lang.Marker):
|
97
|
-
pass
|
98
|
-
|
99
|
-
|
100
|
-
class Shutdown(BaseException): # noqa
|
101
|
-
pass
|
102
|
-
|
103
|
-
|
104
|
-
IoTrampolineTarget: ta.TypeAlias = ta.Callable[[io.BufferedReader], ta.ContextManager[ta.Callable[[], bytes]]]
|
105
|
-
|
106
|
-
|
107
|
-
class IoTrampoline(lang.Abstract):
|
108
|
-
def __init__(
|
109
|
-
self,
|
110
|
-
target: IoTrampolineTarget,
|
111
|
-
*,
|
112
|
-
buffer_size: int | None = None,
|
113
|
-
) -> None:
|
114
|
-
super().__init__()
|
115
|
-
|
116
|
-
self._target = target
|
117
|
-
self._buffer_size = buffer_size
|
118
|
-
|
119
|
-
def _make_buffered_reader(self, raw: ta.Any) -> io.BufferedReader:
|
120
|
-
return io.BufferedReader(
|
121
|
-
raw,
|
122
|
-
**(dict(buffer_size=self._buffer_size) if self._buffer_size is not None else {}),
|
123
|
-
)
|
124
|
-
|
125
|
-
@abc.abstractmethod
|
126
|
-
def close(self, timeout: float | None = None) -> None:
|
127
|
-
raise NotImplementedError
|
128
|
-
|
129
|
-
@abc.abstractmethod
|
130
|
-
def __enter__(self) -> ta.Self:
|
131
|
-
raise NotImplementedError
|
132
|
-
|
133
|
-
@abc.abstractmethod
|
134
|
-
def __exit__(self, exc_type, exc_val, exc_tb):
|
135
|
-
raise NotImplementedError
|
136
|
-
|
137
|
-
@abc.abstractmethod
|
138
|
-
def feed(self, *data: bytes) -> ta.Iterable[bytes]:
|
139
|
-
raise NotImplementedError
|
140
|
-
|
141
|
-
|
142
|
-
#
|
143
|
-
|
144
|
-
|
145
|
-
class ThreadIoTrampoline(IoTrampoline):
|
146
|
-
def __init__(self, target: IoTrampolineTarget, **kwargs: ta.Any) -> None:
|
147
|
-
super().__init__(target, **kwargs)
|
148
|
-
|
149
|
-
self._in: ConditionDeque[bytes | BaseException] = ConditionDeque()
|
150
|
-
self._out: ConditionDeque[
|
151
|
-
bytes | # noqa
|
152
|
-
type[NeedMore] |
|
153
|
-
type[Exited] |
|
154
|
-
BaseException
|
155
|
-
] = ConditionDeque()
|
156
|
-
|
157
|
-
self._proxy = ProxyReadFile(self._read)
|
158
|
-
|
159
|
-
self._thread = threading.Thread(target=self._thread_proc, daemon=True)
|
160
|
-
|
161
|
-
#
|
162
|
-
|
163
|
-
def close(self, timeout: float | None = None) -> None:
|
164
|
-
if not self._thread.is_alive():
|
165
|
-
return
|
166
|
-
self._out.push(Shutdown())
|
167
|
-
self._thread.join(timeout)
|
168
|
-
if self._thread.is_alive():
|
169
|
-
if timeout is not None:
|
170
|
-
raise TimeoutError
|
171
|
-
else:
|
172
|
-
raise RuntimeError('Failed to join thread')
|
173
|
-
|
174
|
-
#
|
175
|
-
|
176
|
-
def __enter__(self) -> ta.Self:
|
177
|
-
self._thread.start()
|
178
|
-
return self
|
179
|
-
|
180
|
-
def __exit__(self, exc_type, exc_val, exc_tb):
|
181
|
-
self.close()
|
182
|
-
|
183
|
-
#
|
184
|
-
|
185
|
-
def _read(self, n: int, /) -> bytes | BaseException:
|
186
|
-
return self._in.pop(if_empty=lambda: self._out.push(NeedMore))
|
187
|
-
|
188
|
-
def _thread_proc(self) -> None:
|
189
|
-
try:
|
190
|
-
with contextlib.closing(self._make_buffered_reader(self._proxy)) as bf: # noqa
|
191
|
-
with self._target(bf) as read:
|
192
|
-
while out := read():
|
193
|
-
self._out.push(out)
|
194
|
-
self._out.push(out)
|
195
|
-
except BaseException as e:
|
196
|
-
self._out.push(e)
|
197
|
-
raise
|
198
|
-
finally:
|
199
|
-
self._out.push(Exited)
|
200
|
-
|
201
|
-
def feed(self, *data: bytes) -> ta.Iterable[bytes]:
|
202
|
-
self._in.push(*data)
|
203
|
-
while True:
|
204
|
-
e = self._out.pop()
|
205
|
-
if e is NeedMore:
|
206
|
-
break
|
207
|
-
elif isinstance(e, BaseException):
|
208
|
-
raise e
|
209
|
-
elif e is Exited:
|
210
|
-
raise RuntimeError('IO thread exited')
|
211
|
-
elif isinstance(e, bytes):
|
212
|
-
yield e
|
213
|
-
if not e:
|
214
|
-
return
|
215
|
-
else:
|
216
|
-
raise TypeError(e)
|
217
|
-
|
218
|
-
|
219
|
-
#
|
220
|
-
|
221
|
-
|
222
|
-
class ThreadletIoTrampoline(IoTrampoline):
|
223
|
-
def __init__(
|
224
|
-
self,
|
225
|
-
target: IoTrampolineTarget,
|
226
|
-
threadlets: tls.Threadlets = tls.GREENLET_THREADLETS,
|
227
|
-
** kwargs: ta.Any,
|
228
|
-
) -> None:
|
229
|
-
super().__init__(target, **kwargs)
|
230
|
-
|
231
|
-
self._proxy = ProxyReadFile(self._read)
|
232
|
-
self._tl: tls.Threadlet = threadlets.spawn(self._g_proc)
|
233
|
-
|
234
|
-
#
|
235
|
-
|
236
|
-
def close(self, timeout: float | None = None) -> None:
|
237
|
-
if self._tl.dead:
|
238
|
-
return
|
239
|
-
out = self._tl.switch(Shutdown())
|
240
|
-
if out is not Exited or not self._tl.dead:
|
241
|
-
raise RuntimeError
|
242
|
-
|
243
|
-
#
|
244
|
-
|
245
|
-
def __enter__(self) -> ta.Self:
|
246
|
-
out = self._tl.switch()
|
247
|
-
if out is not NeedMore:
|
248
|
-
raise RuntimeError
|
249
|
-
return self
|
250
|
-
|
251
|
-
def __exit__(self, exc_type, exc_val, exc_tb):
|
252
|
-
self.close()
|
253
|
-
|
254
|
-
#
|
255
|
-
|
256
|
-
def _read(self, n: int, /) -> bytes:
|
257
|
-
out = check.not_none(self._tl.parent).switch(NeedMore)
|
258
|
-
return out
|
259
|
-
|
260
|
-
def _g_proc(self) -> ta.Any:
|
261
|
-
try:
|
262
|
-
with contextlib.closing(self._make_buffered_reader(self._proxy)) as bf: # noqa
|
263
|
-
with self._target(bf) as read:
|
264
|
-
while out := read():
|
265
|
-
e = check.not_none(self._tl.parent).switch(out)
|
266
|
-
if e is not NeedMore:
|
267
|
-
raise TypeError(e) # noqa
|
268
|
-
e = check.not_none(self._tl.parent).switch(out)
|
269
|
-
if not isinstance(e, Shutdown):
|
270
|
-
raise TypeError(e) # noqa
|
271
|
-
return Exited
|
272
|
-
except BaseException as e:
|
273
|
-
check.not_none(self._tl.parent).throw(e)
|
274
|
-
raise
|
275
|
-
|
276
|
-
def feed(self, *data: bytes) -> ta.Iterable[bytes]:
|
277
|
-
i: bytes | type[NeedMore]
|
278
|
-
for i in data:
|
279
|
-
while True:
|
280
|
-
e = self._tl.switch(i)
|
281
|
-
i = NeedMore
|
282
|
-
if e is NeedMore:
|
283
|
-
break
|
284
|
-
elif isinstance(e, bytes):
|
285
|
-
yield e
|
286
|
-
if not e:
|
287
|
-
return
|
288
|
-
else:
|
289
|
-
raise TypeError(e)
|
omlish/logs/abc.py
DELETED
@@ -1,319 +0,0 @@
|
|
1
|
-
# ruff: noqa: A002 N802 N815
|
2
|
-
import types
|
3
|
-
import typing as ta
|
4
|
-
|
5
|
-
|
6
|
-
##
|
7
|
-
|
8
|
-
|
9
|
-
Level: ta.TypeAlias = int
|
10
|
-
|
11
|
-
|
12
|
-
ExceptionInfo: ta.TypeAlias = tuple[type[BaseException], BaseException, types.TracebackType]
|
13
|
-
|
14
|
-
|
15
|
-
class LogRecord:
|
16
|
-
"""https://docs.python.org/3/library/logging.html#logrecord-attributes"""
|
17
|
-
|
18
|
-
# Name of the logger used to log the call.
|
19
|
-
name: str
|
20
|
-
|
21
|
-
# Human-readable time when the LogRecord was created. By default this is of the form '2003-07-08 16:49:45,896' (the
|
22
|
-
# numbers after the comma are millisecond portion of the time).
|
23
|
-
asctime: str
|
24
|
-
|
25
|
-
# The logged message, computed as msg % args. This is set when Formatter.format() is invoked.
|
26
|
-
message: str
|
27
|
-
|
28
|
-
# The format string passed in the original logging call. Merged with args to produce message, or an arbitrary object
|
29
|
-
# (see Using arbitrary objects as messages).
|
30
|
-
msg: str
|
31
|
-
|
32
|
-
# The tuple of arguments merged into msg to produce message, or a dict whose values are used for the merge (when
|
33
|
-
# there is only one argument, and it is a dictionary).
|
34
|
-
args: tuple
|
35
|
-
|
36
|
-
# Text logging level for the message ('DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL').
|
37
|
-
levelname: str
|
38
|
-
|
39
|
-
# # Numeric logging level for the message (DEBUG, INFO, WARNING, ERROR, CRITICAL).
|
40
|
-
levelno: Level
|
41
|
-
|
42
|
-
# Full pathname of the source file where the logging call was issued (if available).
|
43
|
-
pathname: str
|
44
|
-
|
45
|
-
# Filename portion of pathname.
|
46
|
-
filename: str
|
47
|
-
|
48
|
-
# Module (name portion of filename).
|
49
|
-
module: str
|
50
|
-
|
51
|
-
# Exception tuple (à la sys.exc_info) or, if no exception has occurred, None.
|
52
|
-
exc_info: ExceptionInfo | None
|
53
|
-
|
54
|
-
exc_text: str | None
|
55
|
-
|
56
|
-
# Stack frame information (where available) from the bottom of the stack in the current thread, up to and including
|
57
|
-
# the stack frame of the logging call which resulted in the creation of this record.
|
58
|
-
stack_info: str | None
|
59
|
-
|
60
|
-
# Source line number where the logging call was issued (if available).
|
61
|
-
lineno: int
|
62
|
-
|
63
|
-
# Name of function containing the logging call.
|
64
|
-
funcName: str
|
65
|
-
|
66
|
-
# Time when the LogRecord was created (as returned by time.time_ns() / 1e9).
|
67
|
-
created: float
|
68
|
-
|
69
|
-
# Millisecond portion of the time when the LogRecord was created.
|
70
|
-
msecs: float
|
71
|
-
|
72
|
-
# Time in milliseconds when the LogRecord was created, relative to the time the logging module was loaded.
|
73
|
-
relativeCreated: float
|
74
|
-
|
75
|
-
# Thread ID (if available).
|
76
|
-
thread: int
|
77
|
-
|
78
|
-
# Thread name (if available).
|
79
|
-
threadName: str
|
80
|
-
|
81
|
-
# Process name (if available).
|
82
|
-
processName: str
|
83
|
-
|
84
|
-
# Process ID (if available).
|
85
|
-
process: int
|
86
|
-
|
87
|
-
# asyncio.Task name (if available).
|
88
|
-
taskName: str
|
89
|
-
|
90
|
-
|
91
|
-
##
|
92
|
-
|
93
|
-
|
94
|
-
class Formatter(ta.Protocol):
|
95
|
-
"""https://docs.python.org/3/library/logging.html#formatter-objects"""
|
96
|
-
|
97
|
-
default_time_format: ta.ClassVar[str]
|
98
|
-
default_msec_format: ta.ClassVar[str]
|
99
|
-
|
100
|
-
def formatTime(self, record: LogRecord, datefmt: str | None = None) -> str: ...
|
101
|
-
|
102
|
-
def formatException(self, ei: ExceptionInfo) -> str: ...
|
103
|
-
|
104
|
-
def usesTime(self) -> bool: ...
|
105
|
-
|
106
|
-
def formatMessage(self, record: LogRecord) -> str: ...
|
107
|
-
|
108
|
-
def formatStack(self, stack_info: str) -> str: ...
|
109
|
-
|
110
|
-
def format(self, record: LogRecord) -> str: ...
|
111
|
-
|
112
|
-
|
113
|
-
class BufferingFormatter(ta.Protocol):
|
114
|
-
"""https://docs.python.org/3/library/logging.html#logging.BufferingFormatter"""
|
115
|
-
|
116
|
-
def formatHeader(self, records: ta.Sequence[LogRecord]) -> str: ...
|
117
|
-
|
118
|
-
def formatFooter(self, records: ta.Sequence[LogRecord]) -> str: ...
|
119
|
-
|
120
|
-
def format(self, records: ta.Sequence[LogRecord]) -> str: ...
|
121
|
-
|
122
|
-
|
123
|
-
##
|
124
|
-
|
125
|
-
|
126
|
-
class Filter(ta.Protocol):
|
127
|
-
"""https://docs.python.org/3/library/logging.html#filter-objects"""
|
128
|
-
|
129
|
-
def filter(self, record: LogRecord) -> bool: ...
|
130
|
-
|
131
|
-
|
132
|
-
class Filterer(ta.Protocol):
|
133
|
-
"""A base class for loggers and handlers which allows them to share common code."""
|
134
|
-
|
135
|
-
def addFilter(self, filter: Filter) -> None: ...
|
136
|
-
|
137
|
-
def removeFilter(self, filter: Filter) -> None: ...
|
138
|
-
|
139
|
-
def filter(self, record: LogRecord) -> bool: ...
|
140
|
-
|
141
|
-
|
142
|
-
##
|
143
|
-
|
144
|
-
|
145
|
-
class Handler(Filterer, ta.Protocol):
|
146
|
-
"""https://docs.python.org/3/library/logging.html#handler-objects"""
|
147
|
-
|
148
|
-
level: Level
|
149
|
-
|
150
|
-
def get_name(self) -> str: ...
|
151
|
-
|
152
|
-
def set_name(self, name: str) -> None: ...
|
153
|
-
|
154
|
-
name: str
|
155
|
-
|
156
|
-
def createLock(self) -> None: ...
|
157
|
-
|
158
|
-
def acquire(self) -> None: ...
|
159
|
-
|
160
|
-
def release(self) -> None: ...
|
161
|
-
|
162
|
-
def setLevel(self, level: Level) -> None: ...
|
163
|
-
|
164
|
-
def format(self, record: LogRecord) -> str: ...
|
165
|
-
|
166
|
-
def emit(self, record: LogRecord) -> None: ...
|
167
|
-
|
168
|
-
def handle(self, record: LogRecord) -> bool: ...
|
169
|
-
|
170
|
-
def setFormatter(self, fmt: Formatter) -> None: ...
|
171
|
-
|
172
|
-
def flush(self) -> None: ...
|
173
|
-
|
174
|
-
def close(self) -> None: ...
|
175
|
-
|
176
|
-
def handleError(self, record: LogRecord) -> None: ...
|
177
|
-
|
178
|
-
|
179
|
-
class Stream(ta.Protocol):
|
180
|
-
def write(self, s: str) -> None: ...
|
181
|
-
|
182
|
-
def flush(self) -> None: ... # OPTIONAL METHOD
|
183
|
-
|
184
|
-
def close(self) -> None: ... # OPTIONAL METHOD
|
185
|
-
|
186
|
-
|
187
|
-
class StreamHandler(Handler, ta.Protocol):
|
188
|
-
"""https://docs.python.org/3/library/logging.handlers.html#logging.StreamHandler"""
|
189
|
-
|
190
|
-
terminator: ta.ClassVar[str]
|
191
|
-
|
192
|
-
stream: Stream
|
193
|
-
|
194
|
-
def flush(self) -> None: ...
|
195
|
-
|
196
|
-
def emit(self, record: LogRecord) -> None: ...
|
197
|
-
|
198
|
-
def setStream(self, stream: Stream) -> None: ...
|
199
|
-
|
200
|
-
|
201
|
-
##
|
202
|
-
|
203
|
-
|
204
|
-
class Manager(ta.Protocol):
|
205
|
-
"""There is [under normal circumstances] just one Manager instance, which holds the hierarchy of loggers."""
|
206
|
-
|
207
|
-
root: 'Logger'
|
208
|
-
|
209
|
-
disable: Level
|
210
|
-
|
211
|
-
def getLogger(self, name: str) -> 'Logger': ...
|
212
|
-
|
213
|
-
def setLoggerClass(self, klass: type['Logger']) -> None: ...
|
214
|
-
|
215
|
-
def setLogRecordFactory(self, factory: ta.Callable[..., LogRecord]) -> None: ... # UNREFERENCED?
|
216
|
-
|
217
|
-
|
218
|
-
##
|
219
|
-
|
220
|
-
|
221
|
-
Caller: ta.TypeAlias = tuple[
|
222
|
-
str, # filename
|
223
|
-
int, # lineno
|
224
|
-
str, # name
|
225
|
-
str, # formatted
|
226
|
-
]
|
227
|
-
|
228
|
-
|
229
|
-
class Logger(Filterer, ta.Protocol):
|
230
|
-
"""https://docs.python.org/3/library/logging.html#logger-objects"""
|
231
|
-
|
232
|
-
name: str
|
233
|
-
level: Level
|
234
|
-
parent: ta.Optional['Logger']
|
235
|
-
propagate: bool
|
236
|
-
handlers: list[Handler]
|
237
|
-
disabled: bool
|
238
|
-
|
239
|
-
manager: Manager
|
240
|
-
|
241
|
-
def setLevel(self, level: Level) -> None: ...
|
242
|
-
|
243
|
-
def debug(self, msg: str, *args: ta.Any, **kwargs: ta.Any) -> None: ...
|
244
|
-
def info(self, msg: str, *args: ta.Any, **kwargs: ta.Any) -> None: ...
|
245
|
-
def warning(self, msg: str, *args: ta.Any, **kwargs: ta.Any) -> None: ...
|
246
|
-
def warn(self, msg: str, *args: ta.Any, **kwargs: ta.Any) -> None: ...
|
247
|
-
def error(self, msg: str, *args: ta.Any, **kwargs: ta.Any) -> None: ...
|
248
|
-
def exception(self, msg: str, *args: ta.Any, **kwargs: ta.Any) -> None: ...
|
249
|
-
def critical(self, msg: str, *args: ta.Any, **kwargs: ta.Any) -> None: ...
|
250
|
-
def fatal(self, msg: str, *args: ta.Any, **kwargs: ta.Any) -> None: ...
|
251
|
-
|
252
|
-
def log(self, level: Level, msg: str, *args: ta.Any, **kwargs: ta.Any) -> None: ...
|
253
|
-
|
254
|
-
def findCaller(self, stack_info: bool = False, stacklevel: int = 1) -> Caller: ...
|
255
|
-
|
256
|
-
def makeRecord(
|
257
|
-
self,
|
258
|
-
name,
|
259
|
-
level,
|
260
|
-
fn,
|
261
|
-
lno,
|
262
|
-
msg,
|
263
|
-
args,
|
264
|
-
exc_info,
|
265
|
-
func: str | None = None,
|
266
|
-
extra: ta.Mapping[str, ta.Any] | None = None,
|
267
|
-
sinfo: str | None = None,
|
268
|
-
) -> LogRecord: ...
|
269
|
-
|
270
|
-
def handle(self, record: LogRecord) -> None: ...
|
271
|
-
|
272
|
-
def addHandler(self, hdlr: Handler) -> None: ...
|
273
|
-
|
274
|
-
def removeHandler(self, hdlr: Handler) -> None: ...
|
275
|
-
|
276
|
-
def hasHandlers(self) -> bool: ...
|
277
|
-
|
278
|
-
def callHandlers(self, record: LogRecord) -> None: ...
|
279
|
-
|
280
|
-
def getEffectiveLevel(self) -> Level: ...
|
281
|
-
|
282
|
-
def isEnabledFor(self, level: Level) -> bool: ...
|
283
|
-
|
284
|
-
def getChild(self, suffix: str) -> 'Logger': ...
|
285
|
-
|
286
|
-
|
287
|
-
##
|
288
|
-
|
289
|
-
|
290
|
-
class LoggerAdapter(ta.Protocol):
|
291
|
-
"""https://docs.python.org/3/library/logging.html#loggeradapter-objects"""
|
292
|
-
|
293
|
-
logger: Logger
|
294
|
-
extra: ta.Mapping[str, ta.Any]
|
295
|
-
|
296
|
-
def process(self, msg: str, kwargs: dict[str, ta.Any]) -> tuple[str, dict[str, ta.Any]]: ...
|
297
|
-
|
298
|
-
def debug(self, msg: str, *args: ta.Any, **kwargs: ta.Any) -> None: ...
|
299
|
-
def info(self, msg: str, *args: ta.Any, **kwargs: ta.Any) -> None: ...
|
300
|
-
def warning(self, msg: str, *args: ta.Any, **kwargs: ta.Any) -> None: ...
|
301
|
-
def warn(self, msg: str, *args: ta.Any, **kwargs: ta.Any) -> None: ...
|
302
|
-
def error(self, msg: str, *args: ta.Any, **kwargs: ta.Any) -> None: ...
|
303
|
-
def exception(self, msg: str, *args: ta.Any, **kwargs: ta.Any) -> None: ...
|
304
|
-
def critical(self, msg: str, *args: ta.Any, **kwargs: ta.Any) -> None: ...
|
305
|
-
def fatal(self, msg: str, *args: ta.Any, **kwargs: ta.Any) -> None: ...
|
306
|
-
|
307
|
-
def log(self, level: Level, msg: str, *args: ta.Any, **kwargs: ta.Any) -> None: ...
|
308
|
-
|
309
|
-
def isEnabledFor(self, level: Level) -> bool: ...
|
310
|
-
|
311
|
-
def setLevel(self, level: Level) -> None: ...
|
312
|
-
|
313
|
-
def getEffectiveLevel(self) -> Level: ...
|
314
|
-
|
315
|
-
def hasHandlers(self) -> bool: ...
|
316
|
-
|
317
|
-
manager: Manager
|
318
|
-
|
319
|
-
name: str
|
omlish/logs/color.py
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# ruff: noqa: ANN201 N802
|
2
|
-
import logging
|
3
|
-
import typing as ta
|
4
|
-
|
5
|
-
from ..term import codes as tc
|
6
|
-
from .standard import StandardLogFormatter
|
7
|
-
|
8
|
-
|
9
|
-
##
|
10
|
-
|
11
|
-
|
12
|
-
class ColorLogFormatter(StandardLogFormatter):
|
13
|
-
LEVEL_COLORS: ta.Mapping[int, tc.SGRs.FG] = {
|
14
|
-
logging.WARNING: tc.SGRs.FG.BRIGHT_YELLOW,
|
15
|
-
logging.ERROR: tc.SGRs.FG.BRIGHT_RED,
|
16
|
-
logging.CRITICAL: tc.SGRs.FG.BRIGHT_RED,
|
17
|
-
}
|
18
|
-
|
19
|
-
def formatMessage(self, record):
|
20
|
-
buf = super().formatMessage(record)
|
21
|
-
try:
|
22
|
-
c = self.LEVEL_COLORS[record.levelno]
|
23
|
-
except KeyError:
|
24
|
-
pass
|
25
|
-
else:
|
26
|
-
buf = tc.SGR(c) + buf + tc.SGR(tc.SGRs.RESET)
|
27
|
-
return buf
|
omlish/logs/configs.py
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# ruff: noqa: UP006 UP045
|
2
|
-
# @omlish-lite
|
3
|
-
"""
|
4
|
-
https://docs.python.org/3/howto/logging.html#configuring-logging
|
5
|
-
https://docs.python.org/3/library/logging.config.html#logging-config-dictschema
|
6
|
-
"""
|
7
|
-
import dataclasses as dc
|
8
|
-
import typing as ta
|
9
|
-
|
10
|
-
|
11
|
-
FilterConfig = ta.Dict[str, ta.Any] # ta.TypeAlias
|
12
|
-
FormatterConfig = ta.Dict[str, ta.Any] # ta.TypeAlias
|
13
|
-
HandlerConfig = ta.Dict[str, ta.Any] # ta.TypeAlias
|
14
|
-
LoggerConfig = ta.Dict[str, ta.Any] # ta.TypeAlias
|
15
|
-
|
16
|
-
|
17
|
-
##
|
18
|
-
|
19
|
-
|
20
|
-
@dc.dataclass()
|
21
|
-
class DictConfig:
|
22
|
-
version: int = 1
|
23
|
-
incremental: bool = False
|
24
|
-
disable_existing_loggers: bool = False
|
25
|
-
filters: ta.Dict[str, FilterConfig] = dc.field(default_factory=dict)
|
26
|
-
formatters: ta.Dict[str, FormatterConfig] = dc.field(default_factory=dict)
|
27
|
-
handlers: ta.Dict[str, HandlerConfig] = dc.field(default_factory=dict)
|
28
|
-
loggers: ta.Dict[str, LoggerConfig] = dc.field(default_factory=dict)
|
29
|
-
root: ta.Optional[LoggerConfig] = None
|