Compare commits
No commits in common. "91d70dd3322806d983b78ffeec8a6621504268fd" and "987631c0f307aca70c78f0fbdda4568a6e0a6150" have entirely different histories.
91d70dd332
...
987631c0f3
@ -6,7 +6,7 @@ A python lib came from [Difficult Rocket](https://github.com/shenjackyuanjie/Dif
|
|||||||
|
|
||||||
## Information/信息
|
## Information/信息
|
||||||
|
|
||||||
- Version / 版本: 0.3.5
|
- Version / 版本: 0.3.4
|
||||||
- Author / 作者: shenjackyuanjie <3695888@qq.com>
|
- Author / 作者: shenjackyuanjie <3695888@qq.com>
|
||||||
|
|
||||||
[shenjackyuanjie](https://github.com/shenjackyuanjie)
|
[shenjackyuanjie](https://github.com/shenjackyuanjie)
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
# lndl 0.3
|
# lndl 0.3
|
||||||
|
|
||||||
## 0.3.5
|
|
||||||
|
|
||||||
- 向后移植了一些 `0.4` 的 logger 改动
|
|
||||||
- 其实就是懒得发 0.4, 先测试一下再说
|
|
||||||
|
|
||||||
## 0.3.2/3/4
|
## 0.3.2/3/4
|
||||||
|
|
||||||
仅用于测试新的 `pdm publish` hook
|
仅用于测试新的 `pdm publish` hook
|
||||||
|
@ -3,11 +3,6 @@
|
|||||||
## Logger
|
## Logger
|
||||||
|
|
||||||
- [ ] 达到可用级别
|
- [ ] 达到可用级别
|
||||||
- `Outstream`
|
|
||||||
- `FileCacheOutputStream`
|
|
||||||
- 现在如果输入的文件名包含 `{time}`
|
|
||||||
- 会自动替换为 `time.strftime("%Y-%m-%d_%H-%M-%S")`
|
|
||||||
- 修复了一些之前没有发现的问题
|
|
||||||
|
|
||||||
## Nuitka Compiler Helper
|
## Nuitka Compiler Helper
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ from typing import TYPE_CHECKING
|
|||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from lib_not_dr import loggers, nuitka, types, command
|
from lib_not_dr import loggers, nuitka, types, command
|
||||||
|
|
||||||
_version_ = "0.3.5"
|
_version_ = "0.3.4"
|
||||||
|
|
||||||
# fmt: off
|
# fmt: off
|
||||||
__all__ = [
|
__all__ = [
|
||||||
|
@ -86,11 +86,7 @@ class ConfigStorage(Options):
|
|||||||
return sorted(cycles_set) # 返回排序后的循环列表
|
return sorted(cycles_set) # 返回排序后的循环列表
|
||||||
|
|
||||||
def parse_level(self, level_config: dict) -> Optional[int]:
|
def parse_level(self, level_config: dict) -> Optional[int]:
|
||||||
"""
|
""" """
|
||||||
Parse level config
|
|
||||||
:param level_config:
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
level_found: Tuple[Optional[int], Optional[str]] = (
|
level_found: Tuple[Optional[int], Optional[str]] = (
|
||||||
level_config.get("level"),
|
level_config.get("level"),
|
||||||
level_config.get("level_name"),
|
level_config.get("level_name"),
|
||||||
@ -276,22 +272,21 @@ class ConfigStorage(Options):
|
|||||||
env = ConfigStorage()
|
env = ConfigStorage()
|
||||||
for logger_name, config in logger_config.items():
|
for logger_name, config in logger_config.items():
|
||||||
# get output for logger
|
# get output for logger
|
||||||
if "outputs" in config:
|
if "output" in config:
|
||||||
for i, output_name in enumerate(config["outputs"]):
|
if self.outputs.get(config["output"]) is None:
|
||||||
if self.outputs.get(output_name) is None:
|
if self.fail_outputs.get(config["output"]) is None:
|
||||||
if self.fail_outputs.get(output_name) is None:
|
|
||||||
self.log.error(
|
self.log.error(
|
||||||
f'Logger {logger_name} output {output_name} not found, ignored'
|
f'Logger {logger_name} output {config["output"]} not found, ignored'
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.log.error(
|
self.log.error(
|
||||||
f'Logger {logger_name} require a fail output {output_name}, ignored'
|
f'Logger {logger_name} require a fail output {config["output"]}, ignored'
|
||||||
)
|
)
|
||||||
env.fail_loggers[logger_name] = config
|
env.fail_loggers[logger_name] = config
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
config["outputs"][i] = self.outputs[output_name]
|
config["output"] = self.outputs[config["output"]]
|
||||||
if (level := self.parse_level(config)) is not None:
|
if level := self.parse_level(config) is not None:
|
||||||
config["level"] = level
|
config["level"] = level
|
||||||
if "level_name" in config:
|
if "level_name" in config:
|
||||||
config.pop("level_name")
|
config.pop("level_name")
|
||||||
|
@ -76,9 +76,9 @@ class BaseFormatter(Options):
|
|||||||
template = Template(template)
|
template = Template(template)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return template.substitute(info)
|
return template.substitute(**info)
|
||||||
except (KeyError, ValueError):
|
except (KeyError, ValueError):
|
||||||
return template.safe_substitute(info)
|
return template.safe_substitute(**info)
|
||||||
|
|
||||||
def _format(self, message: FormattingMessage) -> FormattingMessage:
|
def _format(self, message: FormattingMessage) -> FormattingMessage:
|
||||||
"""
|
"""
|
||||||
|
@ -44,8 +44,6 @@ class BaseColorFormatter(BaseFormatter):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def get_color(self, message: FormattingMessage) -> str:
|
def get_color(self, message: FormattingMessage) -> str:
|
||||||
if message[0].level in self.color:
|
|
||||||
return self.color[message[0].level]
|
|
||||||
for level in self.color:
|
for level in self.color:
|
||||||
if message[0].level <= level:
|
if message[0].level <= level:
|
||||||
break
|
break
|
||||||
|
@ -61,11 +61,10 @@ class StdioOutputStream(BaseOutputStream):
|
|||||||
return None
|
return None
|
||||||
if message.level < self.level:
|
if message.level < self.level:
|
||||||
return None
|
return None
|
||||||
out_msg = self.formatter.format_message(message)
|
|
||||||
if message.flush is not None:
|
if message.flush is not None:
|
||||||
print(out_msg, end="", flush=message.flush)
|
print(self.formatter.format_message(message), end="", flush=message.flush)
|
||||||
else:
|
else:
|
||||||
print(out_msg, end="", flush=True)
|
print(self.formatter.format_message(message), end="", flush=True)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def write_stderr(self, message: LogMessage) -> None:
|
def write_stderr(self, message: LogMessage) -> None:
|
||||||
@ -116,7 +115,6 @@ class FileCacheOutputStream(BaseOutputStream):
|
|||||||
flush_timer: Optional[threading.Timer] = None
|
flush_timer: Optional[threading.Timer] = None
|
||||||
|
|
||||||
file_path: Path = Path("./logs")
|
file_path: Path = Path("./logs")
|
||||||
# if contain {time} -> time.strftime("%Y-%m-%d_%H-%M-%S", time.gmtime(time.time)
|
|
||||||
file_name: str
|
file_name: str
|
||||||
# file mode: always 'a'
|
# file mode: always 'a'
|
||||||
file_encoding: str = "utf-8"
|
file_encoding: str = "utf-8"
|
||||||
@ -140,17 +138,9 @@ class FileCacheOutputStream(BaseOutputStream):
|
|||||||
file_swap_on_both: bool = False # swap file when both size and time limit reached
|
file_swap_on_both: bool = False # swap file when both size and time limit reached
|
||||||
|
|
||||||
def init(self, **kwargs) -> bool:
|
def init(self, **kwargs) -> bool:
|
||||||
# 时间取整
|
|
||||||
self.file_start_time = round(time.time())
|
self.file_start_time = round(time.time())
|
||||||
# 初始化文件名
|
|
||||||
if "{time}" in self.file_name:
|
|
||||||
self.file_name = self.file_name.format(time=time.strftime(
|
|
||||||
"%Y-%m-%d_%H-%M-%S", time.gmtime(self.file_start_time)
|
|
||||||
))
|
|
||||||
# 初始化缓存
|
|
||||||
if self.text_cache is None:
|
if self.text_cache is None:
|
||||||
self.text_cache = io.StringIO()
|
self.text_cache = io.StringIO()
|
||||||
# 检查文件名
|
|
||||||
self.get_file_path()
|
self.get_file_path()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -234,7 +224,8 @@ class FileCacheOutputStream(BaseOutputStream):
|
|||||||
if file_time > self.file_time_limit:
|
if file_time > self.file_time_limit:
|
||||||
time_pass = False
|
time_pass = False
|
||||||
if (self.file_swap_on_both and size_pass and time_pass) or (
|
if (self.file_swap_on_both and size_pass and time_pass) or (
|
||||||
not self.file_swap_on_both and (size_pass or time_pass)):
|
not self.file_swap_on_both and (size_pass or time_pass)
|
||||||
|
):
|
||||||
# 两个都满足
|
# 两个都满足
|
||||||
# 或者只有一个满足
|
# 或者只有一个满足
|
||||||
if size_pass and time_pass:
|
if size_pass and time_pass:
|
||||||
@ -252,7 +243,6 @@ class FileCacheOutputStream(BaseOutputStream):
|
|||||||
if text == "":
|
if text == "":
|
||||||
return None
|
return None
|
||||||
current_file = self.check_flush()
|
current_file = self.check_flush()
|
||||||
# 检查文件是否存在
|
|
||||||
if not current_file.exists():
|
if not current_file.exists():
|
||||||
current_file.parent.mkdir(parents=True, exist_ok=True)
|
current_file.parent.mkdir(parents=True, exist_ok=True)
|
||||||
current_file.touch(exist_ok=True)
|
current_file.touch(exist_ok=True)
|
||||||
|
@ -13,13 +13,4 @@ nuitka_config_type = Dict[str, Union[str, bool, List[Union[str, tuple]]]]
|
|||||||
raw_config_type = Dict[str, Union[nuitka_config_type, str]]
|
raw_config_type = Dict[str, Union[nuitka_config_type, str]]
|
||||||
parse_config_function = Callable[[raw_config_type], nuitka_config_type]
|
parse_config_function = Callable[[raw_config_type], nuitka_config_type]
|
||||||
|
|
||||||
# fmt: off
|
__all__ = ["reader", "compile", "raw_config_type", "parse_config_function", "nuitka_config_type"]
|
||||||
__all__ = [
|
|
||||||
"reader",
|
|
||||||
"compile",
|
|
||||||
"raw_config_type",
|
|
||||||
"parse_config_function",
|
|
||||||
"nuitka_config_type"
|
|
||||||
]
|
|
||||||
# fmt: on
|
|
||||||
|
|
||||||
|
@ -8,10 +8,3 @@
|
|||||||
TMD 啊啊啊啊啊啊啊啊啊
|
TMD 啊啊啊啊啊啊啊啊啊
|
||||||
这里不是用来直接调用的啊啊啊啊啊
|
这里不是用来直接调用的啊啊啊啊啊
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from lib_not_dr.nuitka.reader import cli_main
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
cli_main()
|
|
||||||
|
|
||||||
main = cli_main
|
|
||||||
|
Loading…
Reference in New Issue
Block a user