diff --git a/README.md b/README.md index 7334246..41ceebc 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.2.0 +- Version / 版本: 0.2.1 - Author / 作者: shenjackyuanjie <3695888@qq.com> > [shenjackyuanjie](https://github.com/shenjackyuanjie) @@ -30,7 +30,7 @@ pip install lib-not-dr[nuitka] ### Logger > WIP -> 等待 0.2.0 +> 等待 0.3.0 ```python title="logger.py" from lib_not_dr.logger.logger import Logger diff --git a/docs/change_log.md b/docs/change_log.md index a5bc9e3..314464f 100644 --- a/docs/change_log.md +++ b/docs/change_log.md @@ -1,5 +1,17 @@ # Change log / 更新日志 +## 0.2.1 + +### Fix + +- `Logger` + - `MainFormatter` + - 修复了会导致 `ColorFormatter` 崩溃的问题 + +## 0.2.0 + +> 内容和 0.2.0-rc.10 相同 + ## 0.2.0-rc.10 ### lndl-nuitka diff --git a/src/lib_not_dr/logger/formatter/colors.py b/src/lib_not_dr/logger/formatter/colors.py index 7cf97be..4f90b24 100644 --- a/src/lib_not_dr/logger/formatter/colors.py +++ b/src/lib_not_dr/logger/formatter/colors.py @@ -88,7 +88,8 @@ class LevelColorFormatter(BaseColorFormatter): # 添加颜色 if color == '' or color == RESET_COLOR: return message - message[1]['level'] = f'{color}{message[1]["level"]}{RESET_COLOR}' + if 'level' in message[1]: + message[1]['level'] = f'{color}{message[1]["level"]}{RESET_COLOR}' return message @@ -126,8 +127,9 @@ class LoggerColorFormatter(BaseColorFormatter): # 添加颜色 if color == '' or color == RESET_COLOR: return message - message[1]['logger_name'] = f'{color}{message[1]["logger_name"]}{RESET_COLOR}' - if message[1].get('logger_tag') is not None and message[1].get('logger_tag') != ' ': + if 'logger_name' in message[1]: + message[1]['logger_name'] = f'{color}{message[1]["logger_name"]}{RESET_COLOR}' + if 'logger_tag' in message[1] and message[1].get('logger_tag') != ' ': message[1]['logger_tag'] = f'{color}{message[1]["logger_tag"]}{RESET_COLOR}' return message @@ -166,7 +168,8 @@ class TimeColorFormatter(BaseColorFormatter): # 添加颜色 if color == '' or color == RESET_COLOR: return message - message[1]['log_time'] = f'{color}{message[1]["log_time"]}{RESET_COLOR}' + if 'log_time' in message[1]: + message[1]['log_time'] = f'{color}{message[1]["log_time"]}{RESET_COLOR}' return message @@ -210,7 +213,7 @@ class TraceColorFormatter(BaseColorFormatter): if color == '' or color == RESET_COLOR: return message for name in ('log_source', 'log_line', 'log_function'): - if message[1].get(name) is not None: + if name in message[1]: message[1][name] = f'{color}{message[1][name]}{RESET_COLOR}' return message @@ -249,8 +252,9 @@ class MessageColorFormatter(BaseColorFormatter): # 添加颜色 if color == '' or color == RESET_COLOR: return message - if message[1]['messages'][-1] == '\n': - message[1]['messages'] = f'{color}{message[1]["messages"][:-1]}{RESET_COLOR}\n' - else: - message[1]['messages'] = f'{color}{message[1]["messages"]}{RESET_COLOR}' + if 'messages' in message[1]: + if message[1]['messages'][-1] == '\n': + message[1]['messages'] = f'{color}{message[1]["messages"][:-1]}{RESET_COLOR}\n' + else: + message[1]['messages'] = f'{color}{message[1]["messages"]}{RESET_COLOR}' return message