fix(log): 文件日志保留异常堆栈 (#7286)

未捕获异常经 localized_unhandled_exception_handler 写入文件日志时只保留正文,异常三元组未进入文件写入链路,导致 moviepilot.log 丢失异常类型与堆栈。现将 exc_info 在调用方线程规范化为三元组并随 LogEntry 携带到文件格式化器。
This commit is contained in:
MoviePilot Contributor
2026-11-03 16:07:43 +00:00
committed by InfinityPacer
parent c301783bc2
commit e550ec6dd8
6 changed files with 142 additions and 20 deletions

View File

@@ -40,9 +40,20 @@ class _CapturingLogWriter:
"""
self.entries: list[tuple[str, str, Path]] = []
def write_log(self, level: str, message: str, file_path: Path) -> None:
def write_log(
self,
level: str,
message: str,
file_path: Path,
exc_info: tuple | None = None,
) -> None:
"""
保存单条日志的级别、内容和目标路径。
:param level: 日志等级名称
:param message: 已经格式化的日志正文
:param file_path: 目标日志文件路径
:param exc_info: 已规范化的异常三元组,本测试写入器忽略该信息
"""
self.entries.append((level, message, file_path))