Bug tracker

If you liked this item, please rate it up on Steam Workshop page.

Author: 老王天天写bug

Last revision: 10 Oct, 2021 at 13:33 UTC

File size: 240.59 KB

On Steam Workshop

Description:

More detailed crash logs.

This mod is fully localized, but now I haven’t finished writing the English version of the document, please wait patiently.

What Bug tracker does?

This mod helps you quickly locate the crash point.

[sm.ms]

Log synchronization

When joining a room as a client, if the server has an error, it will only show "you are disconnected from the server". This mod will send the error message to local. You can view the log directly on the client side, whether it is a world with cave or a dedicated server.
Note: Players without administrator privileges cannot view the log and will still only show disconnection screen.

One click to open the log

Click the green text, you can directly get access to the error log.

[sm.ms]

[sm.ms]

Locate bug

Find where bad code is.

Crash point (dark red)
Indicates the actual location where the error occurred. In basic game or in a specific mod.

Traceback (red)
Mod is in the chain that causes errors.

Warning (Yellow)
Mod is not the cause of crash, but it has some other problems of its own.

Safety (green)
No problem.

This feature uses Lua debug trace to analyze mods that cause crashes. The analysis results are for reference only. In the case of a large number of mods, the process of causing a crash can be quite complex, and 100% positioning accuracy is not guaranteed.

Log sending

Found a mod that really has a problem, but don’t know how to notify the author to fix it?
This mod comes with a log sending feature, which sends error messages to the mod developer with a single click. Of course, mod developers have to make adaptations beforehand.

Does the mod have any bugs of its own?

I’m not sure. If you feel something wrong with it, please contact me.

Message for mod developers

错误追踪器内置了日志发送功能,玩家只需要点击按钮,就能把日志直接发到你的手里。
支持两种发送方法: 邮箱、URL。

要实现这个功能,你的mod需要进行一些简单的配置。请在 modinfo.lua 或 modmain.lua中
以全局变量的形式声明`bugtracker_config`表,所有配置都应写在这张表内。类似这样:

bugtracker_config = {
email = "[email protected]",
upload_client_log = true,
upload_server_log = false,
— 其它配置项目…
}

1. 设定接收条件
你可以指定哪些日志允许上传,避免收到一些无意义的报错信息。
可跳过此设置,使用默认值。

bugtracker_config = {
— * 是否接受客户端报错日志,默认true。
— * 大部分mod都包含会在客户端运行的代码,所以建议都设置为true。
upload_client_log = true,

— * 是否接受服务器报错日志,客户端mod默认false,服务器mod默认true。
— * 建议默认。
upload_server_log = true,

— * 是否接受其它mod引起的报错日志,默认true。
— * 可能有助于解决mod之间的冲突
upload_other_mods_crash_log = true,

— 其它配置项目…
}

2. 设定邮箱
如果你希望玩家将日志发送到你指定的邮箱,你需要添加`email`键,如下所示:

bugtracker_config = {
— * 注意: 不要设置成工作的邮箱!建议注册一个新邮箱专门用于接收日志。
email = "[email protected]",

— * 邮件内容默认为英文,如果你想接收中文邮件,请将`lang`键设置为"CHI"。
lang = "CHI",

— 其它配置项目…
}

这样一来,当玩家点击上传日志按钮后,日志会发送至你的邮箱。
每日发送上限为100封。(理解理解,我怕发的太频繁账号被网易封了)

3. 设定URL
如果你恰好有一个网络服务器,强烈建议你配置一个专用的上传URL,日志信息将直接以POST的方法发送至你的服务器。
该配置的优先级高于`email`。如果同时设置`email`和`url`,只有`url`会生效。

bugtracker_config = {
— * 请务必带上协议,如 http://https://
url = "http://127.0.0.1:8000/demo/",

— 其它配置项目…
}

上传的数据结构为 <摘要区字节数> 摘要区(json格式)日志内容(纯字符串)
这是使用python-django的后端解析示例,可供参考。(我没学过php和java,所以没有例子)

import re
import json
from django.http import HttpResponse

def parsebody(body: bytes) -> dict:
”’饥荒只能POST字符串,服务器需要对上传的内容进行解析。
数据结构为 <摘要区字节数> 摘要区(json格式) 日志内容(纯字符串)
摘要区包含一些基础信息,日志则包含详细的报错内容。

摘要结构:
gameversion <str> 饥荒版本号
platform <str> 运行平台
playername <str> 向您发送日志的玩家昵称
modname <str> 模组名
modversion <str> 模组版本号
diagnose <str> 诊断信息
timestamp <int> 崩溃发生的时间戳
ingame <bool> 崩溃发生在世界启动后
isserver <bool> 崩溃点位于服务器
isdedicated <bool> 崩溃点位于专用服务器
apiversion <str> 错误追踪器版本号
”’
match = re.match(b"^<(\d+)>.", body)
if match is not None:
# parse abstract length
abslenstr = match.group(1)
abslen = int(abslenstr)
# don’t forget `<` and `>`!
absstart = len(abslenstr) + 2
# parse abstract, note abstract may contain utf-8 character.
jsonstr = body[absstart: absstart + abslen].decode("utf-8")

# Here we get abstract!
abstract = json.loads(jsonstr)
# Here we get log content!
log = body[absstart + abslen: ].decode("utf-8")

return {
"abstract" : abstract,
"log" : log,
}

def demo(request):
”’ Your url function ”’
if request.method == "POST":
result = parsebody(request.body)
if result:
abstract = result["abstract"]
log = request["log"]
# Now do anything you want to do.
# (For example, save log file in the database or send an email.)

# Actually, BugTracker doesn’t handle response, but you need this to avoid 500.
return HttpResponse("")

本mod所有代码开源无混淆。