diff --git a/client/entities.go b/client/entities.go index d6d70038..06cb1abd 100644 --- a/client/entities.go +++ b/client/entities.go @@ -177,6 +177,7 @@ type ( LogEvent struct { Type string Message string + Dump []byte } ServerUpdatedEvent struct { diff --git a/client/global.go b/client/global.go index dc9d2903..73a1cd7d 100644 --- a/client/global.go +++ b/client/global.go @@ -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, + }) +} diff --git a/client/network.go b/client/network.go index d4b4e42b..77cae726 100644 --- a/client/network.go +++ b/client/network.go @@ -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) } }()