update crash report

This commit is contained in:
shenjack-mac 2023-04-23 00:15:36 +08:00
parent af2c312d10
commit 2d2ba88986
5 changed files with 16 additions and 3 deletions

6
DR.py
View File

@ -8,6 +8,8 @@ import time
import cProfile
import traceback
from io import StringIO
# TODO 默认位置配置文件
# TODO 可自定义工作路径
@ -89,6 +91,10 @@ def main() -> None:
print(error_format['error.unknown'])
print(error)
crash.create_crash_report(error)
cache_steam = StringIO()
crash.write_info_to_cache(cache_steam)
text = cache_steam.getvalue()
print(text)
else:
crash.record_thread = False
print(crash.all_thread)

View File

@ -113,7 +113,7 @@ class _DR_runtime(Options):
API_version: Version = Api_version # DR SDK API 版本
DR_long_version: int = long_version # DR SDK 内部协议版本 (不要问我为什么不用 Version我也在考虑
DR_Mod_List: List[Tuple[str, Version]] = [] # DR Mod 列表
DR_Mod_List: List[Tuple[str, Version]] = [] # DR Mod 列表 (name, version)
DR_Rust_version: Version = DR_rust_version # 后面要去掉的 DR_rs 版本
DR_Rust_get_version: Optional[Version] = None # 后面也要去掉的 DR_rs 版本
@ -177,6 +177,7 @@ class _DR_runtime(Options):
except ImportError:
print(f'ImportError when loading mod {mod_path}')
traceback.print_exc()
self.DR_Mod_List = [(mod, Version('0.0.0-unknown')) for mod in mods]
return mods

View File

@ -40,7 +40,7 @@ file_error = {FileNotFoundError: 'no {filetype} file was founded!:\n file name:
def load_file(file_name: str,
stack: Union[str, list, dict] = None,
stack: Union[str, list, dict, None] = None,
raise_error: bool = True,
encoding: str = 'utf-8') -> Union[dict, ElementTree.ElementTree]:
f_type = file_name[file_name.rfind('.') + 1:] # 从最后一个.到末尾 (截取文件格式)

View File

@ -49,7 +49,10 @@
- Add `mod_path: str` field
- Add `DR_Mod_List: List[Tuple[str, Version]]` field
- Add `load_mods() -> None` method
- Add `find_mods -> List[str]` method
- Add `find_mods -> List[str]` method
- 现在游戏崩溃时会自动在 stdio 中输出崩溃日志 内容跟 crash report 中的基本相同
- Now when the game crashes, it will automatically output the crash log in stdio
- The content of the crash log is basically the same as the crash report
### Mod Loader

View File

@ -102,6 +102,9 @@ class Version:
version_str += '+' + str(self.build)
return version_str
def __repr__(self):
return 'Version({})'.format(self.__str__())
def __getitem__(self, index):
if index < len(self.component):
return self.component[index]