Browse Source

Only use the EntryFormatter for normal entries.

ConfChange entries also have a Data field but the application-supplied
formatter won't know what to do with them.
Ben Darnell 10 years ago
parent
commit
b53dc0826e
1 changed files with 3 additions and 3 deletions
  1. 3 3
      raft/util.go

+ 3 - 3
raft/util.go

@@ -84,10 +84,10 @@ func DescribeMessage(m pb.Message, f EntryFormatter) string {
 // Entry for debugging.
 // Entry for debugging.
 func DescribeEntry(e pb.Entry, f EntryFormatter) string {
 func DescribeEntry(e pb.Entry, f EntryFormatter) string {
 	var formatted string
 	var formatted string
-	if f == nil {
-		formatted = fmt.Sprintf("%q", e.Data)
-	} else {
+	if e.Type == pb.EntryNormal && f != nil {
 		formatted = f(e.Data)
 		formatted = f(e.Data)
+	} else {
+		formatted = fmt.Sprintf("%q", e.Data)
 	}
 	}
 	return fmt.Sprintf("%d/%d %s %s", e.Term, e.Index, e.Type, formatted)
 	return fmt.Sprintf("%d/%d %s %s", e.Term, e.Index, e.Type, formatted)
 }
 }