style: 移除 server 慢消息无意义的堆栈信息,优化消息的 String 函数返回的不再是简单的消息类型
This commit is contained in:
parent
9371890638
commit
ba24b09c71
|
@ -3,6 +3,7 @@ package server
|
|||
import (
|
||||
"github.com/kercylan98/minotaur/utils/hash"
|
||||
"github.com/kercylan98/minotaur/utils/log"
|
||||
"github.com/kercylan98/minotaur/utils/super"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -128,7 +129,17 @@ func (slf *Message) MessageType() MessageType {
|
|||
|
||||
// String 返回消息的字符串表示
|
||||
func (slf *Message) String() string {
|
||||
return slf.t.String()
|
||||
var info = struct {
|
||||
Type string `json:"type,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Packet string `json:"packet,omitempty"`
|
||||
}{
|
||||
Type: slf.t.String(),
|
||||
Name: slf.name,
|
||||
Packet: string(slf.packet),
|
||||
}
|
||||
|
||||
return string(super.MarshalJSON(info))
|
||||
}
|
||||
|
||||
// String 返回消息类型的字符串表示
|
||||
|
|
|
@ -676,8 +676,8 @@ func (slf *Server) low(message *Message, present time.Time, expect time.Duration
|
|||
var fields = make([]log.Field, 0, len(message.marks)+4)
|
||||
fields = append(fields, log.String("type", messageNames[message.t]), log.String("cost", cost.String()), log.String("message", message.String()))
|
||||
fields = append(fields, message.marks...)
|
||||
fields = append(fields, log.Stack("stack"))
|
||||
log.Warn("Server", fields...)
|
||||
//fields = append(fields, log.Stack("stack"))
|
||||
log.Warn("ServerLowMessage", fields...)
|
||||
slf.OnMessageLowExecEvent(message, cost)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue