mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 19:17:38 +08:00
feat: dump packet on decoder panic
This commit is contained in:
parent
6c1b622107
commit
5a59cc656c
@ -177,6 +177,7 @@ type (
|
||||
LogEvent struct {
|
||||
Type string
|
||||
Message string
|
||||
Dump []byte
|
||||
}
|
||||
|
||||
ServerUpdatedEvent struct {
|
||||
|
@ -723,3 +723,11 @@ func (c *QQClient) Trace(msg string, args ...interface{}) {
|
||||
Message: fmt.Sprintf(msg, args...),
|
||||
})
|
||||
}
|
||||
|
||||
func (c *QQClient) Dump(msg string, data []byte, args ...interface{}) {
|
||||
c.dispatchLogEvent(&LogEvent{
|
||||
Type: "DUMP",
|
||||
Message: fmt.Sprintf(msg, args...),
|
||||
Dump: data,
|
||||
})
|
||||
}
|
||||
|
@ -322,6 +322,7 @@ func (c *QQClient) netLoop() {
|
||||
defer func() {
|
||||
if pan := recover(); pan != nil {
|
||||
c.Error("panic on decoder %v : %v\n%s", pkt.CommandName, pan, debug.Stack())
|
||||
c.Dump("packet decode error: %v - %v", pkt.Payload, pkt.CommandName, pan)
|
||||
}
|
||||
}()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user