From 7fc18c6dc9af8f70bbb6803e7b3d7f9f3a6e0609 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 18 Nov 2023 23:11:54 +0800 Subject: [PATCH] feat: add logger to docs --- README.md | 2 +- docs/change_log.md | 7 +++++++ lib_not_dr/__init__.py | 2 +- lib_not_dr/logger/formatter/__init__.py | 13 ++++++++++++- pyproject.toml | 2 +- 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7f971a7..104cb8a 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ A python lib came from [Difficult Rocket](https://github.com/shenjackyuanjie/Dif ## Information/信息 -- Version / 版本: 0.1.8 +- Version / 版本: 0.2.0-alpha0 - Author / 作者: shenjackyuanjie 3695888@qq.com > [shenjackyuanjie](https://github/shenjackyuanjie) diff --git a/docs/change_log.md b/docs/change_log.md index b4d455b..ab89d2c 100644 --- a/docs/change_log.md +++ b/docs/change_log.md @@ -1,5 +1,12 @@ # Change log / 更新日志 +## 0.2.0-alpha0 + +### Logger + +- 添加了 Logger (虽说 0.1.8 就有了) +- 目前入口点位于 `lib_not_dr.logger.logger.Logger` + ## 0.1.8 - 为 `types.Options` 添加了 `_check_option` 选项 diff --git a/lib_not_dr/__init__.py b/lib_not_dr/__init__.py index 9852726..71fb463 100644 --- a/lib_not_dr/__init__.py +++ b/lib_not_dr/__init__.py @@ -4,4 +4,4 @@ # All rights reserved # ------------------------------- -__version__ = '0.1.8' +__version__ = '0.2.0-alpha0' diff --git a/lib_not_dr/logger/formatter/__init__.py b/lib_not_dr/logger/formatter/__init__.py index 9ccc6e7..53a4ac4 100644 --- a/lib_not_dr/logger/formatter/__init__.py +++ b/lib_not_dr/logger/formatter/__init__.py @@ -16,6 +16,12 @@ from lib_not_dr.logger.structure import LogMessage, FormattingMessage if TYPE_CHECKING: from lib_not_dr.logger.formatter.colors import BaseColorFormatter +__all__ = [ + 'BaseFormatter', + 'MainFormatter', + 'StdFormatter' +] + class BaseFormatter(Options): name = 'BaseFormatter' @@ -189,7 +195,7 @@ class StdFormatter(BaseFormatter): enable_color: bool = True - sub_formatter: List[BaseFormatter] = [MainFormatter()] + sub_formatter: List[BaseFormatter] = [] from lib_not_dr.logger.formatter.colors import (LevelColorFormatter, LoggerColorFormatter, TimeColorFormatter, @@ -204,6 +210,7 @@ class StdFormatter(BaseFormatter): def __init__(self, enable_color: bool = True, sub_formatter: Optional[List[BaseFormatter]] = None, + main_formatter: Optional[MainFormatter] = None, color_formatters: Optional[List[BaseFormatter]] = None, **kwargs) -> None: """ @@ -219,6 +226,10 @@ class StdFormatter(BaseFormatter): self.sub_formatter = sub_formatter if color_formatters is not None: self.color_formatters = color_formatters + if main_formatter is not None and isinstance(main_formatter, MainFormatter): + self.main_formatter = main_formatter + else: + self.main_formatter = MainFormatter() super().__init__(**kwargs) def _format(self, message: FormattingMessage) -> FormattingMessage: diff --git a/pyproject.toml b/pyproject.toml index 25c5bb3..36f41e8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [project] -version = "0.1.8" +version = "0.2.0-alpha0" name = "lib-not-dr" description = "A python lib created from Difficult Rocket development" readme = "README.md"