Fix | 修复了一些之前没发现的问题(
This commit is contained in:
parent
4fa5089819
commit
a8f326dca9
@ -6,7 +6,7 @@
|
||||
- `Outstream`
|
||||
- `FileCacheOutputStream`
|
||||
- 现在如果输入的文件名包含 `{time}`
|
||||
- 会自动替换为 `time.strftime("%Y-%m-%d|%H-%M-%S")`
|
||||
- 会自动替换为 `time.strftime("%Y-%m-%d_%H-%M-%S")`
|
||||
|
||||
## Nuitka Compiler Helper
|
||||
|
||||
|
@ -86,7 +86,11 @@ class ConfigStorage(Options):
|
||||
return sorted(cycles_set) # 返回排序后的循环列表
|
||||
|
||||
def parse_level(self, level_config: dict) -> Optional[int]:
|
||||
""" """
|
||||
"""
|
||||
Parse level config
|
||||
:param level_config:
|
||||
:return:
|
||||
"""
|
||||
level_found: Tuple[Optional[int], Optional[str]] = (
|
||||
level_config.get("level"),
|
||||
level_config.get("level_name"),
|
||||
@ -273,19 +277,20 @@ class ConfigStorage(Options):
|
||||
for logger_name, config in logger_config.items():
|
||||
# get output for logger
|
||||
if "outputs" in config:
|
||||
if self.outputs.get(config["outputs"]) is None:
|
||||
if self.fail_outputs.get(config["outputs"]) is None:
|
||||
for i, output_name in enumerate(config["outputs"]):
|
||||
if self.outputs.get(output_name) is None:
|
||||
if self.fail_outputs.get(output_name) is None:
|
||||
self.log.error(
|
||||
f'Logger {logger_name} output {config["output"]} not found, ignored'
|
||||
f'Logger {logger_name} output {output_name} not found, ignored'
|
||||
)
|
||||
else:
|
||||
self.log.error(
|
||||
f'Logger {logger_name} require a fail output {config["output"]}, ignored'
|
||||
f'Logger {logger_name} require a fail output {output_name}, ignored'
|
||||
)
|
||||
env.fail_loggers[logger_name] = config
|
||||
continue
|
||||
else:
|
||||
config["outputs"] = self.outputs[config["outputs"]]
|
||||
config["outputs"][i] = self.outputs[output_name]
|
||||
if level := self.parse_level(config) is not None:
|
||||
config["level"] = level
|
||||
if "level_name" in config:
|
||||
|
@ -75,10 +75,11 @@ class BaseFormatter(Options):
|
||||
elif isinstance(template, str):
|
||||
template = Template(template)
|
||||
|
||||
print(message, info, template)
|
||||
try:
|
||||
return template.substitute(**info)
|
||||
return template.substitute(info)
|
||||
except (KeyError, ValueError):
|
||||
return template.safe_substitute(**info)
|
||||
return template.safe_substitute(info)
|
||||
|
||||
def _format(self, message: FormattingMessage) -> FormattingMessage:
|
||||
"""
|
||||
|
@ -44,6 +44,8 @@ class BaseColorFormatter(BaseFormatter):
|
||||
}
|
||||
|
||||
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:
|
||||
if message[0].level <= level:
|
||||
break
|
||||
|
@ -115,7 +115,7 @@ class FileCacheOutputStream(BaseOutputStream):
|
||||
flush_timer: Optional[threading.Timer] = None
|
||||
|
||||
file_path: Path = Path("./logs")
|
||||
# if contain {time} -> time.strftime("%Y-%m-%d %H-%M-%S", time.gmtime(time.time)
|
||||
# if contain {time} -> time.strftime("%Y-%m-%d_%H-%M-%S", time.gmtime(time.time)
|
||||
file_name: str
|
||||
# file mode: always 'a'
|
||||
file_encoding: str = "utf-8"
|
||||
@ -144,7 +144,7 @@ class FileCacheOutputStream(BaseOutputStream):
|
||||
# 初始化文件名
|
||||
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)
|
||||
"%Y-%m-%d_%H-%M-%S", time.gmtime(self.file_start_time)
|
||||
))
|
||||
# 初始化缓存
|
||||
if self.text_cache is None:
|
||||
|
Loading…
Reference in New Issue
Block a user