diff options
author | Tulir Asokan <tulir@maunium.net> | 2019-04-13 00:51:58 +0300 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2019-04-13 00:51:58 +0300 |
commit | 43a7bdab7262c015b50e3e673e80389f9514f9ca (patch) | |
tree | 0efd957e49ebe6c6350a3b9067e3068b24b2448c /ui/messages/base.go | |
parent | abd21affc42ad65968c946c3bbd6c63eba342981 (diff) |
Add better stringification for UI message types for debugging
Diffstat (limited to 'ui/messages/base.go')
-rw-r--r-- | ui/messages/base.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/ui/messages/base.go b/ui/messages/base.go index c3ee1f0..cb9b371 100644 --- a/ui/messages/base.go +++ b/ui/messages/base.go @@ -18,6 +18,7 @@ package messages import ( "encoding/json" + "fmt" "time" "maunium.net/go/gomuks/config" @@ -286,3 +287,17 @@ func (msg *BaseMessage) DrawReply(screen mauview.Screen) mauview.Screen { msg.ReplyTo.Draw(replyScreen) return mauview.NewProxyScreen(screen, 0, replyHeight+2, width, height-replyHeight-2) } + +func (msg *BaseMessage) String() string { + return fmt.Sprintf(`&messages.BaseMessage{ + ID="%s", TxnID="%s", + Type="%s", Timestamp=%s, + Sender={ID="%s", Name="%s", Color=#%X}, + IsService=%t, IsHighlight=%t, +}`, + msg.MsgID, msg.MsgTxnID, + msg.MsgType, msg.MsgTimestamp.String(), + msg.MsgSenderID, msg.MsgSender, msg.MsgSenderColor.Hex(), + msg.MsgIsService, msg.MsgIsHighlight, + ) +} |