py.lib.aw_log
0:41b53fd5637e
Go to Latest
py.lib.aw_log/src/aw_log/console.py
..init
2 # devel.a0fs.ru -- aw_log.console -- v0.r202402.1
6 from sys import stderr, stdout
7 from typing import TextIO, Optional
9 from . import AbstractLogBase
12 class NullLog(AbstractLogBase):
13 def _write(self, mark: str, msg: Any):
17 class AbstractConsoleLog(AbstractLogBase):
18 def __init__(self, prefix: str = 'main'):
19 super().__init__(prefix)
20 self.fd: Optional[TextIO] = None
22 def _write(self, mark: str, msg: Any):
24 raise ValueError(f'Не определён канал логирования')
27 for l in super()._write_helper(mark, msg):
28 self.fd.write(f'{tm} | {l}')
31 class StdoutLog(AbstractConsoleLog):
32 def __init__(self, prefix: str = 'main'):
33 super().__init__(prefix)
37 class StderrLog(AbstractConsoleLog):
38 def __init__(self, prefix: str = 'main'):
39 super().__init__(prefix)