omlish 0.0.0.dev426__py3-none-any.whl → 0.0.0.dev428__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.
@@ -0,0 +1,276 @@
1
+ # ruff: noqa: UP006 UP007 UP045 UP046
2
+ # @omlish-lite
3
+ import abc
4
+ import sys
5
+ import time
6
+ import types
7
+ import typing as ta
8
+
9
+ from ..lite.abstract import Abstract
10
+ from .callers import LoggingCaller
11
+ from .infos import LoggingAsyncioTaskInfo
12
+ from .infos import LoggingMultiprocessingInfo
13
+ from .infos import LoggingProcessInfo
14
+ from .infos import LoggingSourceFileInfo
15
+ from .infos import LoggingThreadInfo
16
+ from .levels import LogLevel
17
+ from .levels import NamedLogLevel
18
+ from .times import LoggingTimeFields
19
+
20
+
21
+ LoggingExcInfoTuple = ta.Tuple[ta.Type[BaseException], BaseException, ta.Optional[types.TracebackType]] # ta.TypeAlias
22
+ LoggingExcInfo = ta.Union[BaseException, LoggingExcInfoTuple] # ta.TypeAlias
23
+ LoggingExcInfoArg = ta.Union[LoggingExcInfo, bool, None] # ta.TypeAlias
24
+
25
+
26
+ ##
27
+
28
+
29
+ class LoggingContext(Abstract):
30
+ @property
31
+ @abc.abstractmethod
32
+ def level(self) -> NamedLogLevel:
33
+ raise NotImplementedError
34
+
35
+ #
36
+
37
+ @property
38
+ @abc.abstractmethod
39
+ def time_ns(self) -> int:
40
+ raise NotImplementedError
41
+
42
+ @property
43
+ @abc.abstractmethod
44
+ def times(self) -> LoggingTimeFields:
45
+ raise NotImplementedError
46
+
47
+ #
48
+
49
+ @property
50
+ @abc.abstractmethod
51
+ def exc_info(self) -> ta.Optional[LoggingExcInfo]:
52
+ raise NotImplementedError
53
+
54
+ @property
55
+ @abc.abstractmethod
56
+ def exc_info_tuple(self) -> ta.Optional[LoggingExcInfoTuple]:
57
+ raise NotImplementedError
58
+
59
+ #
60
+
61
+ @abc.abstractmethod
62
+ def caller(self) -> ta.Optional[LoggingCaller]:
63
+ raise NotImplementedError
64
+
65
+ @abc.abstractmethod
66
+ def source_file(self) -> ta.Optional[LoggingSourceFileInfo]:
67
+ raise NotImplementedError
68
+
69
+ #
70
+
71
+ @abc.abstractmethod
72
+ def thread(self) -> ta.Optional[LoggingThreadInfo]:
73
+ raise NotImplementedError
74
+
75
+ @abc.abstractmethod
76
+ def process(self) -> ta.Optional[LoggingProcessInfo]:
77
+ raise NotImplementedError
78
+
79
+ @abc.abstractmethod
80
+ def multiprocessing(self) -> ta.Optional[LoggingMultiprocessingInfo]:
81
+ raise NotImplementedError
82
+
83
+ @abc.abstractmethod
84
+ def asyncio_task(self) -> ta.Optional[LoggingAsyncioTaskInfo]:
85
+ raise NotImplementedError
86
+
87
+
88
+ ##
89
+
90
+
91
+ class CaptureLoggingContext(LoggingContext, Abstract):
92
+ class AlreadyCapturedError(Exception):
93
+ pass
94
+
95
+ class NotCapturedError(Exception):
96
+ pass
97
+
98
+ @abc.abstractmethod
99
+ def capture(self) -> None:
100
+ """Must be cooperatively called only from the expected locations."""
101
+
102
+ raise NotImplementedError
103
+
104
+
105
+ @ta.final
106
+ class CaptureLoggingContextImpl(CaptureLoggingContext):
107
+ @ta.final
108
+ class NOT_SET: # noqa
109
+ def __new__(cls, *args, **kwargs): # noqa
110
+ raise TypeError
111
+
112
+ #
113
+
114
+ def __init__(
115
+ self,
116
+ level: LogLevel,
117
+ *,
118
+ time_ns: ta.Optional[int] = None,
119
+
120
+ exc_info: LoggingExcInfoArg = False,
121
+
122
+ caller: ta.Union[LoggingCaller, ta.Type[NOT_SET], None] = NOT_SET,
123
+ stack_offset: int = 0,
124
+ stack_info: bool = False,
125
+ ) -> None:
126
+ self._level: NamedLogLevel = level if level.__class__ is NamedLogLevel else NamedLogLevel(level) # type: ignore[assignment] # noqa
127
+
128
+ #
129
+
130
+ if time_ns is None:
131
+ time_ns = time.time_ns()
132
+ self._time_ns: int = time_ns
133
+
134
+ #
135
+
136
+ if exc_info is True:
137
+ sys_exc_info = sys.exc_info()
138
+ if sys_exc_info[0] is not None:
139
+ exc_info = sys_exc_info
140
+ else:
141
+ exc_info = None
142
+ elif exc_info is False:
143
+ exc_info = None
144
+
145
+ if exc_info is not None:
146
+ self._exc_info: ta.Optional[LoggingExcInfo] = exc_info
147
+ if isinstance(exc_info, BaseException):
148
+ self._exc_info_tuple: ta.Optional[LoggingExcInfoTuple] = (type(exc_info), exc_info, exc_info.__traceback__) # noqa
149
+ else:
150
+ self._exc_info_tuple = exc_info
151
+
152
+ #
153
+
154
+ if caller is not CaptureLoggingContextImpl.NOT_SET:
155
+ self._caller = caller # type: ignore[assignment]
156
+ else:
157
+ self._stack_offset = stack_offset
158
+ self._stack_info = stack_info
159
+
160
+ ##
161
+
162
+ @property
163
+ def level(self) -> NamedLogLevel:
164
+ return self._level
165
+
166
+ #
167
+
168
+ @property
169
+ def time_ns(self) -> int:
170
+ return self._time_ns
171
+
172
+ _times: LoggingTimeFields
173
+
174
+ @property
175
+ def times(self) -> LoggingTimeFields:
176
+ try:
177
+ return self._times
178
+ except AttributeError:
179
+ pass
180
+
181
+ times = self._times = LoggingTimeFields.build(self.time_ns)
182
+ return times
183
+
184
+ #
185
+
186
+ _exc_info: ta.Optional[LoggingExcInfo] = None
187
+ _exc_info_tuple: ta.Optional[LoggingExcInfoTuple] = None
188
+
189
+ @property
190
+ def exc_info(self) -> ta.Optional[LoggingExcInfo]:
191
+ return self._exc_info
192
+
193
+ @property
194
+ def exc_info_tuple(self) -> ta.Optional[LoggingExcInfoTuple]:
195
+ return self._exc_info_tuple
196
+
197
+ ##
198
+
199
+ _stack_offset: int
200
+ _stack_info: bool
201
+
202
+ def inc_stack_offset(self, ofs: int = 1) -> 'CaptureLoggingContext':
203
+ if hasattr(self, '_stack_offset'):
204
+ self._stack_offset += ofs
205
+ return self
206
+
207
+ _has_captured: bool = False
208
+
209
+ _caller: ta.Optional[LoggingCaller]
210
+ _source_file: ta.Optional[LoggingSourceFileInfo]
211
+
212
+ _thread: ta.Optional[LoggingThreadInfo]
213
+ _process: ta.Optional[LoggingProcessInfo]
214
+ _multiprocessing: ta.Optional[LoggingMultiprocessingInfo]
215
+ _asyncio_task: ta.Optional[LoggingAsyncioTaskInfo]
216
+
217
+ def capture(self) -> None:
218
+ if self._has_captured:
219
+ raise CaptureLoggingContextImpl.AlreadyCapturedError
220
+ self._has_captured = True
221
+
222
+ if not hasattr(self, '_caller'):
223
+ self._caller = LoggingCaller.find(
224
+ self._stack_offset + 1,
225
+ stack_info=self._stack_info,
226
+ )
227
+
228
+ if (caller := self._caller) is not None:
229
+ self._source_file = LoggingSourceFileInfo.build(caller.file_path)
230
+ else:
231
+ self._source_file = None
232
+
233
+ self._thread = LoggingThreadInfo.build()
234
+ self._process = LoggingProcessInfo.build()
235
+ self._multiprocessing = LoggingMultiprocessingInfo.build()
236
+ self._asyncio_task = LoggingAsyncioTaskInfo.build()
237
+
238
+ #
239
+
240
+ def caller(self) -> ta.Optional[LoggingCaller]:
241
+ try:
242
+ return self._caller
243
+ except AttributeError:
244
+ raise CaptureLoggingContext.NotCapturedError from None
245
+
246
+ def source_file(self) -> ta.Optional[LoggingSourceFileInfo]:
247
+ try:
248
+ return self._source_file
249
+ except AttributeError:
250
+ raise CaptureLoggingContext.NotCapturedError from None
251
+
252
+ #
253
+
254
+ def thread(self) -> ta.Optional[LoggingThreadInfo]:
255
+ try:
256
+ return self._thread
257
+ except AttributeError:
258
+ raise CaptureLoggingContext.NotCapturedError from None
259
+
260
+ def process(self) -> ta.Optional[LoggingProcessInfo]:
261
+ try:
262
+ return self._process
263
+ except AttributeError:
264
+ raise CaptureLoggingContext.NotCapturedError from None
265
+
266
+ def multiprocessing(self) -> ta.Optional[LoggingMultiprocessingInfo]:
267
+ try:
268
+ return self._multiprocessing
269
+ except AttributeError:
270
+ raise CaptureLoggingContext.NotCapturedError from None
271
+
272
+ def asyncio_task(self) -> ta.Optional[LoggingAsyncioTaskInfo]:
273
+ try:
274
+ return self._asyncio_task
275
+ except AttributeError:
276
+ raise CaptureLoggingContext.NotCapturedError from None
omlish/logs/infos.py CHANGED
@@ -9,8 +9,19 @@ import typing as ta
9
9
  ##
10
10
 
11
11
 
12
+ class _LoggingContextInfo:
13
+ def __mro_entries__(self, bases):
14
+ return ()
15
+
16
+
17
+ LoggingContextInfo: type = ta.cast(ta.Any, _LoggingContextInfo())
18
+
19
+
20
+ ##
21
+
22
+
12
23
  @ta.final
13
- class LoggingSourceFileInfo(ta.NamedTuple):
24
+ class LoggingSourceFileInfo(LoggingContextInfo, ta.NamedTuple): # type: ignore[misc]
14
25
  file_name: str
15
26
  module: str
16
27
 
@@ -36,7 +47,7 @@ class LoggingSourceFileInfo(ta.NamedTuple):
36
47
 
37
48
 
38
49
  @ta.final
39
- class LoggingThreadInfo(ta.NamedTuple):
50
+ class LoggingThreadInfo(LoggingContextInfo, ta.NamedTuple): # type: ignore[misc]
40
51
  ident: int
41
52
  native_id: ta.Optional[int]
42
53
  name: str
@@ -54,7 +65,7 @@ class LoggingThreadInfo(ta.NamedTuple):
54
65
 
55
66
 
56
67
  @ta.final
57
- class LoggingProcessInfo(ta.NamedTuple):
68
+ class LoggingProcessInfo(LoggingContextInfo, ta.NamedTuple): # type: ignore[misc]
58
69
  pid: int
59
70
 
60
71
  @classmethod
@@ -68,7 +79,7 @@ class LoggingProcessInfo(ta.NamedTuple):
68
79
 
69
80
 
70
81
  @ta.final
71
- class LoggingMultiprocessingInfo(ta.NamedTuple):
82
+ class LoggingMultiprocessingInfo(LoggingContextInfo, ta.NamedTuple): # type: ignore[misc]
72
83
  process_name: str
73
84
 
74
85
  @classmethod
@@ -86,7 +97,7 @@ class LoggingMultiprocessingInfo(ta.NamedTuple):
86
97
 
87
98
 
88
99
  @ta.final
89
- class LoggingAsyncioTaskInfo(ta.NamedTuple):
100
+ class LoggingAsyncioTaskInfo(LoggingContextInfo, ta.NamedTuple): # type: ignore[misc]
90
101
  name: str
91
102
 
92
103
  @classmethod
@@ -100,6 +111,9 @@ class LoggingAsyncioTaskInfo(ta.NamedTuple):
100
111
  except Exception: # noqa
101
112
  return None
102
113
 
114
+ if task is None:
115
+ return None
116
+
103
117
  return cls(
104
118
  task.get_name(), # Always non-None
105
119
  )
omlish/logs/modules.py CHANGED
@@ -2,9 +2,12 @@
2
2
  import logging
3
3
  import typing as ta
4
4
 
5
+ from .base import Logger
6
+ from .std.adapters import StdLogger
7
+
5
8
 
6
9
  ##
7
10
 
8
11
 
9
- def get_module_logger(mod_globals: ta.Mapping[str, ta.Any]) -> logging.Logger:
10
- return logging.getLogger(mod_globals.get('__name__'))
12
+ def get_module_logger(mod_globals: ta.Mapping[str, ta.Any]) -> Logger:
13
+ return StdLogger(logging.getLogger(mod_globals.get('__name__'))) # noqa
omlish/logs/protocols.py CHANGED
@@ -16,16 +16,16 @@ class LoggerLike(ta.Protocol):
16
16
 
17
17
  #
18
18
 
19
- def debug(self, msg: str, *args: ta.Any, **kwargs: ta.Any) -> None: ... # noqa
19
+ def log(self, level: LogLevel, msg: str, /, *args: ta.Any, **kwargs: ta.Any) -> None: ... # noqa
20
20
 
21
- def info(self, msg: str, *args: ta.Any, **kwargs: ta.Any) -> None: ... # noqa
21
+ def debug(self, msg: str, /, *args: ta.Any, **kwargs: ta.Any) -> None: ... # noqa
22
22
 
23
- def warning(self, msg: str, *args: ta.Any, **kwargs: ta.Any) -> None: ... # noqa
23
+ def info(self, msg: str, /, *args: ta.Any, **kwargs: ta.Any) -> None: ... # noqa
24
24
 
25
- def error(self, msg: str, *args: ta.Any, **kwargs: ta.Any) -> None: ... # noqa
25
+ def warning(self, msg: str, /, *args: ta.Any, **kwargs: ta.Any) -> None: ... # noqa
26
26
 
27
- def exception(self, msg: str, *args: ta.Any, **kwargs: ta.Any) -> None: ... # noqa
27
+ def error(self, msg: str, /, *args: ta.Any, **kwargs: ta.Any) -> None: ... # noqa
28
28
 
29
- def critical(self, msg: str, *args: ta.Any, **kwargs: ta.Any) -> None: ... # noqa
29
+ def exception(self, msg: str, /, *args: ta.Any, **kwargs: ta.Any) -> None: ... # noqa
30
30
 
31
- def log(self, level: LogLevel, msg: str, *args: ta.Any, **kwargs: ta.Any) -> None: ... # noqa
31
+ def critical(self, msg: str, /, *args: ta.Any, **kwargs: ta.Any) -> None: ... # noqa
@@ -1,10 +1,12 @@
1
+ # ruff: noqa: UP007
1
2
  # @omlish-lite
2
3
  import logging
3
4
  import typing as ta
4
5
 
5
6
  from ..base import Logger
6
- from ..base import LoggingContext
7
- from ..base import LogLevel
7
+ from ..base import LoggingMsgFn
8
+ from ..contexts import CaptureLoggingContext
9
+ from ..levels import LogLevel
8
10
  from .records import LoggingContextLogRecord
9
11
 
10
12
 
@@ -24,15 +26,17 @@ class StdLogger(Logger):
24
26
  def get_effective_level(self) -> LogLevel:
25
27
  return self._std.getEffectiveLevel()
26
28
 
27
- def _log(self, ctx: LoggingContext, msg: str, *args: ta.Any) -> None:
29
+ def _log(self, ctx: CaptureLoggingContext, msg: ta.Union[str, tuple, LoggingMsgFn], *args: ta.Any) -> None:
28
30
  if not self.is_enabled_for(ctx.level):
29
31
  return
30
32
 
31
- ctx.build_caller()
33
+ ctx.capture()
34
+
35
+ ms, args = self._prepare_msg_args(msg, *args)
32
36
 
33
37
  rec = LoggingContextLogRecord(
34
38
  name=self._std.name,
35
- msg=msg,
39
+ msg=ms,
36
40
  args=args,
37
41
 
38
42
  _logging_context=ctx,
@@ -8,10 +8,12 @@ import typing as ta
8
8
 
9
9
 
10
10
  class ListLoggingHandler(logging.Handler):
11
- def __init__(self) -> None:
11
+ def __init__(self, record_list: ta.Optional[ta.List[logging.LogRecord]] = None) -> None:
12
12
  super().__init__()
13
13
 
14
- self.records: ta.List[logging.LogRecord] = []
14
+ if record_list is None:
15
+ record_list = []
16
+ self.records: ta.List[logging.LogRecord] = record_list
15
17
 
16
18
  def emit(self, record: logging.LogRecord) -> None:
17
19
  self.records.append(record)
@@ -5,8 +5,9 @@ import logging
5
5
  import sys
6
6
  import typing as ta
7
7
 
8
- from ..base import LoggingContext
9
- from ..base import LoggingExcInfoTuple
8
+ from ...lite.check import check
9
+ from ..contexts import LoggingContext
10
+ from ..contexts import LoggingExcInfoTuple
10
11
  from ..warnings import LoggingSetupWarning
11
12
 
12
13
 
@@ -268,19 +269,33 @@ class LoggingContextLogRecord(logging.LogRecord):
268
269
  self.msecs: float = times.msecs
269
270
  self.relativeCreated: float = times.relative_created
270
271
 
271
- thread = ctx.thread
272
- self.thread: ta.Optional[int] = thread.ident
273
- self.threadName: ta.Optional[str] = thread.name
272
+ if logging.logThreads:
273
+ thread = check.not_none(ctx.thread())
274
+ self.thread: ta.Optional[int] = thread.ident
275
+ self.threadName: ta.Optional[str] = thread.name
276
+ else:
277
+ self.thread = None
278
+ self.threadName = None
274
279
 
275
- process = ctx.process
276
- self.process: ta.Optional[int] = process.pid
280
+ if logging.logProcesses:
281
+ process = check.not_none(ctx.process())
282
+ self.process: ta.Optional[int] = process.pid
283
+ else:
284
+ self.process = None
277
285
 
278
- if (mp := ctx.multiprocessing) is not None:
279
- self.processName: ta.Optional[str] = mp.process_name
286
+ if logging.logMultiprocessing:
287
+ if (mp := ctx.multiprocessing()) is not None:
288
+ self.processName: ta.Optional[str] = mp.process_name
289
+ else:
290
+ self.processName = None
280
291
  else:
281
292
  self.processName = None
282
293
 
283
- if (at := ctx.asyncio_task) is not None:
284
- self.taskName: ta.Optional[str] = at.name
294
+ # Absent <3.12
295
+ if getattr(logging, 'logAsyncioTasks', None):
296
+ if (at := ctx.asyncio_task()) is not None:
297
+ self.taskName: ta.Optional[str] = at.name
298
+ else:
299
+ self.taskName = None
285
300
  else:
286
301
  self.taskName = None
omlish/logs/times.py CHANGED
@@ -4,13 +4,14 @@ import logging
4
4
  import time
5
5
  import typing as ta
6
6
 
7
+ from .infos import LoggingContextInfo
7
8
  from .warnings import LoggingSetupWarning
8
9
 
9
10
 
10
11
  ##
11
12
 
12
13
 
13
- class LoggingTimeFields(ta.NamedTuple):
14
+ class LoggingTimeFields(LoggingContextInfo, ta.NamedTuple): # type: ignore[misc]
14
15
  """Maps directly to stdlib `logging.LogRecord` fields, and must be kept in sync with it."""
15
16
 
16
17
  created: float
@@ -8,6 +8,12 @@ TODO:
8
8
  - TypeMap style weak cache of issubclass queries
9
9
  - wait.. lazily load the class for virtual subclass queries? xor support virtual bases?
10
10
  - weakref class dict keys?
11
+ - cheap_discover_package_root_dirs: Seq[str] | None = None or smth
12
+ - maaaybe.. add an EnvVar? OMLISH_MANIFEST_ROOT_DIRS? if set to : delimited, turns off package disco and overrides
13
+ scan_root_dirs
14
+ - currently the cli cant subprocess itself and keep manifests working
15
+ - EnvVar cls is already lite
16
+
11
17
  """
12
18
  import dataclasses as dc
13
19
  import importlib.machinery
omlish/secrets/secrets.py CHANGED
@@ -11,7 +11,6 @@ TODO:
11
11
  """
12
12
  import abc
13
13
  import collections
14
- import logging
15
14
  import os
16
15
  import sys
17
16
  import time
@@ -21,12 +20,13 @@ import typing as ta
21
20
  from .. import dataclasses as dc
22
21
  from .. import lang
23
22
  from .. import marshal as msh
23
+ from ..logs import all as logs
24
24
 
25
25
 
26
26
  msh.register_global_module_import('.marshal', __package__)
27
27
 
28
28
 
29
- log = logging.getLogger(__name__)
29
+ log = logs.get_module_logger(globals())
30
30
 
31
31
 
32
32
  ##
@@ -269,7 +269,7 @@ class LoggingSecrets(Secrets):
269
269
  self,
270
270
  child: Secrets,
271
271
  *,
272
- log: logging.Logger | None = None, # noqa
272
+ log: logs.LoggerLike | None = None, # noqa
273
273
  ) -> None:
274
274
  super().__init__()
275
275
 
@@ -3,11 +3,11 @@
3
3
  import abc
4
4
  import concurrent.futures as cf
5
5
  import dataclasses as dc
6
- import logging
7
6
  import socket
8
7
  import typing as ta
9
8
 
10
9
  from ...lite.abstract import Abstract
10
+ from ...logs.protocols import LoggerLike
11
11
  from ..addresses import SocketAndAddress
12
12
  from ..handlers import SocketHandler
13
13
  from ..io import SocketIoPair
@@ -142,7 +142,7 @@ class ExecutorSocketServerHandler(SocketServerHandler_):
142
142
  @dc.dataclass(frozen=True)
143
143
  class ExceptionLoggingSocketServerHandler(SocketServerHandler_):
144
144
  handler: SocketServerHandler
145
- log: logging.Logger
145
+ log: LoggerLike
146
146
 
147
147
  ignored: ta.Optional[ta.Container[ta.Type[Exception]]] = None
148
148
 
@@ -11,6 +11,7 @@ import typing as ta
11
11
  from ...lite.abstract import Abstract
12
12
  from ...lite.contextmanagers import ExitStacked
13
13
  from ...lite.contextmanagers import defer
14
+ from ...logs.protocols import LoggerLike
14
15
  from ..addresses import SocketAndAddress
15
16
  from ..bind import SocketBinder
16
17
  from ..io import close_socket_immediately
@@ -20,7 +21,7 @@ from .handlers import SocketServerHandler
20
21
  ##
21
22
 
22
23
 
23
- class SocketServer(Abstract):
24
+ class SocketServer:
24
25
  _DEFAULT_LOGGER = logging.getLogger('.'.join([__name__, 'SocketServer']))
25
26
 
26
27
  def __init__(
@@ -29,7 +30,7 @@ class SocketServer(Abstract):
29
30
  handler: SocketServerHandler,
30
31
  *,
31
32
  on_error: ta.Optional[ta.Callable[[BaseException, ta.Optional[SocketAndAddress]], None]] = None,
32
- error_logger: ta.Optional[logging.Logger] = _DEFAULT_LOGGER,
33
+ error_logger: ta.Optional[LoggerLike] = _DEFAULT_LOGGER,
33
34
  poll_interval: float = .5,
34
35
  shutdown_timeout: ta.Optional[float] = None,
35
36
  ) -> None:
@@ -1,9 +1,9 @@
1
1
  # ruff: noqa: UP006 UP007 UP045
2
2
  # @omlish-lite
3
3
  import dataclasses as dc
4
- import logging
5
4
  import typing as ta
6
5
 
6
+ from ...logs.protocols import LoggerLike
7
7
  from ..addresses import SocketAndAddress
8
8
  from ..io import close_socket_immediately
9
9
  from .handlers import SocketServerHandler
@@ -17,7 +17,7 @@ from .handlers import SocketServerHandler_
17
17
  class SslErrorHandlingSocketServerHandler(SocketServerHandler_):
18
18
  handler: SocketServerHandler
19
19
 
20
- log: ta.Optional[logging.Logger] = None
20
+ log: ta.Optional[LoggerLike] = None
21
21
 
22
22
  #
23
23
 
@@ -9,6 +9,7 @@ import typing as ta
9
9
 
10
10
  from ..lite.abstract import Abstract
11
11
  from ..lite.timeouts import Timeout
12
+ from ..logs.protocols import LoggerLike
12
13
  from .wrap import subprocess_maybe_shell_wrap_exec
13
14
 
14
15
 
@@ -55,12 +56,12 @@ class VerboseCalledProcessError(subprocess.CalledProcessError):
55
56
 
56
57
 
57
58
  class BaseSubprocesses(Abstract):
58
- DEFAULT_LOGGER: ta.ClassVar[ta.Optional[logging.Logger]] = None
59
+ DEFAULT_LOGGER: ta.ClassVar[ta.Optional[LoggerLike]] = None
59
60
 
60
61
  def __init__(
61
62
  self,
62
63
  *,
63
- log: ta.Optional[logging.Logger] = None,
64
+ log: ta.Optional[LoggerLike] = None,
64
65
  try_exceptions: ta.Optional[ta.Tuple[ta.Type[Exception], ...]] = None,
65
66
  ) -> None:
66
67
  super().__init__()
@@ -68,7 +69,7 @@ class BaseSubprocesses(Abstract):
68
69
  self._log = log if log is not None else self.DEFAULT_LOGGER
69
70
  self._try_exceptions = try_exceptions if try_exceptions is not None else self.DEFAULT_TRY_EXCEPTIONS
70
71
 
71
- def set_logger(self, log: ta.Optional[logging.Logger]) -> None:
72
+ def set_logger(self, log: ta.Optional[LoggerLike]) -> None:
72
73
  self._log = log
73
74
 
74
75
  #
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: omlish
3
- Version: 0.0.0.dev426
3
+ Version: 0.0.0.dev428
4
4
  Summary: omlish
5
5
  Author: wrmsr
6
6
  License-Expression: BSD-3-Clause