From c185bdaf955dd71328eac79fdb40027571fa047a Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Wed, 20 Jan 2016 11:02:50 -0400 Subject: [PATCH] raft: Improve formatting of DescribeMessage --- raft/util.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/raft/util.go b/raft/util.go index a7cbaf7ca..8d4c41900 100644 --- a/raft/util.go +++ b/raft/util.go @@ -65,13 +65,19 @@ func DescribeMessage(m pb.Message, f EntryFormatter) string { fmt.Fprintf(&buf, "%x->%x %v Term:%d Log:%d/%d", m.From, m.To, m.Type, m.Term, m.LogTerm, m.Index) if m.Reject { fmt.Fprintf(&buf, " Rejected") + if m.RejectHint != 0 { + fmt.Fprintf(&buf, "(Hint:%d)", m.RejectHint) + } } if m.Commit != 0 { fmt.Fprintf(&buf, " Commit:%d", m.Commit) } if len(m.Entries) > 0 { fmt.Fprintf(&buf, " Entries:[") - for _, e := range m.Entries { + for i, e := range m.Entries { + if i != 0 { + buf.WriteString(", ") + } buf.WriteString(DescribeEntry(e, f)) } fmt.Fprintf(&buf, "]")