13 lines
406 B
Python
13 lines
406 B
Python
from __future__ import annotations
|
|
|
|
import faulthandler
|
|
from pathlib import Path
|
|
|
|
|
|
def enable_crash_handler(log_dir: str | Path) -> None:
|
|
"""启用faulthandler,将崩溃堆栈写入日志文件"""
|
|
log_dir = Path(log_dir)
|
|
log_dir.mkdir(parents=True, exist_ok=True)
|
|
crash_log = open(log_dir / "posefit-crash.log", "a", buffering=1)
|
|
faulthandler.enable(file=crash_log, all_threads=True)
|