py.lib.aw_log

Yohn Y. 2024-10-30 Parent:1e93862d5063 Child:5db1541311ef

6:9155a66edb31 Browse Files

.. 1.202410.1 . Изменение структуры проекта под новые вызовы SDK Python . Убраны версии с отдельный файлов, они кажутся избыточними. * Изменено формирование записей о исключении, для большего соответствия логике журналирования - Перенос `NullLog` на уровень модуля и повышение его универсальности для замены других классов.

README.md pyproject.toml setup.py src/aw_log/console.py src/aw_log/file.py src/aw_log/syslog.py

     1.1 --- a/README.md	Wed Oct 30 19:16:36 2024 +0300
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,10 +0,0 @@
     1.4 -Описание
     1.5 ---------
     1.6 -
     1.7 -Модуль реализации системы логирования к которой привычен автор.
     1.8 -
     1.9 -
    1.10 -Ресурсы
    1.11 --------
    1.12 -
    1.13 -* Адрес собранного модуля: https://l.fs.a0fs.ru/py.repo
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/pyproject.toml	Wed Oct 30 19:29:41 2024 +0300
     2.3 @@ -0,0 +1,21 @@
     2.4 +[build-system]
     2.5 +# Minimum requirements for the build system to execute.
     2.6 +requires = ["setuptools", "wheel"]  # PEP 508 specifications.
     2.7 +
     2.8 +[project]
     2.9 +name = "aw_log"           # Имя проекта
    2.10 +dynamic = ["version", "description"]
    2.11 +requires-python = ">=3.9"
    2.12 +
    2.13 +
    2.14 +[project.urls]
    2.15 +documentation = "https://devel.a0fs.ru/"
    2.16 +source = "https://repo.devel.a0fs.ru/py.lib.aw_log/"
    2.17 +download = "https://py-repo.devel.a0fs.ru"
    2.18 +
    2.19 +[project.license]
    2.20 +file = "LICENSE"
    2.21 +
    2.22 +[[project.authors]]
    2.23 +name = 'awgur'
    2.24 +email = 'devel@a0fs.ru'
    2.25 \ No newline at end of file
     3.1 --- a/setup.py	Wed Oct 30 19:16:36 2024 +0300
     3.2 +++ b/setup.py	Wed Oct 30 19:29:41 2024 +0300
     3.3 @@ -3,12 +3,8 @@
     3.4  
     3.5  setup(
     3.6      name='aw_log',
     3.7 -    version='0.202402.2',
     3.8 +    version='1.202410.2',
     3.9      packages=['aw_log'],
    3.10      package_dir={'aw_log': 'src/aw_log'},
    3.11 -    url='https://devel.a0fs.ru/py.lib.aw_log',
    3.12 -    license='BSD',
    3.13 -    author='awgur',
    3.14 -    author_email='devel@a0fs.ru',
    3.15 -    description='Реализация логирования'
    3.16 +    description='Реализация журналирования'
    3.17  )
     4.1 --- a/src/aw_log/console.py	Wed Oct 30 19:16:36 2024 +0300
     4.2 +++ b/src/aw_log/console.py	Wed Oct 30 19:29:41 2024 +0300
     4.3 @@ -1,5 +1,4 @@
     4.4  # coding: utf-8
     4.5 -# devel.a0fs.ru -- aw_log.console -- v0.r202402.1
     4.6  
     4.7  from typing import Any
     4.8  from time import ctime
     4.9 @@ -9,11 +8,6 @@
    4.10  from . import AbstractLogBase
    4.11  
    4.12  
    4.13 -class NullLog(AbstractLogBase):
    4.14 -    def _write(self, mark: str, msg: Any):
    4.15 -        pass
    4.16 -
    4.17 -
    4.18  class AbstractConsoleLog(AbstractLogBase):
    4.19      def __init__(self, prefix: str = 'main'):
    4.20          super().__init__(prefix)
     5.1 --- a/src/aw_log/file.py	Wed Oct 30 19:16:36 2024 +0300
     5.2 +++ b/src/aw_log/file.py	Wed Oct 30 19:29:41 2024 +0300
     5.3 @@ -1,5 +1,4 @@
     5.4  # coding: utf-8
     5.5 -# devel.a0fs.ru -- aw_log.file -- v0.r202402.1
     5.6  
     5.7  from typing import Any
     5.8  from time import monotonic, ctime
     5.9 @@ -14,11 +13,6 @@
    5.10                              # после которого, выполняется принудительный сброс буферов
    5.11  
    5.12  
    5.13 -class NullLog(AbstractLogBase):
    5.14 -    def _write(self, mark: str, msg: Any):
    5.15 -        pass
    5.16 -
    5.17 -
    5.18  class AbstractFileLog(AbstractLogBase):
    5.19      def __init__(self, prefix: str = 'main'):
    5.20          super().__init__(prefix)
    5.21 @@ -140,10 +134,12 @@
    5.22      def logrotate_rotate(self):
    5.23          d = date.today()
    5.24          file_name = f'{self.logrotate_base}-{d}.log'
    5.25 -        self.fd.flush()
    5.26 +        _fd = self.fd
    5.27          self.fd = self._open_file(file_name)
    5.28          self.logrotate_date = d
    5.29          self.flush(no_rotate=True)
    5.30 +        _fd.flush()
    5.31 +        _fd.close()
    5.32  
    5.33      def sub_log(self, name: str):
    5.34          return self.__class__(
     6.1 --- a/src/aw_log/syslog.py	Wed Oct 30 19:16:36 2024 +0300
     6.2 +++ b/src/aw_log/syslog.py	Wed Oct 30 19:29:41 2024 +0300
     6.3 @@ -1,5 +1,4 @@
     6.4  # coding: utf-8
     6.5 -# devel.a0fs.ru -- aw_log.syslog -- v0.r202402.1
     6.6  
     6.7  import syslog
     6.8  from typing import Any
     6.9 @@ -24,6 +23,9 @@
    6.10          super().__init__(prefix=prefix)
    6.11          self.facility = facility
    6.12  
    6.13 +    def sub_log(self, name: str):
    6.14 +        return self.__class__(f'{self.prefix}/{name}', self.facility)
    6.15 +
    6.16      def _write(self, mark: str, msg: Any):
    6.17          flag = self.facility | PRIORITY_BY_MARK.get(mark, syslog.LOG_INFO)
    6.18