diff --git a/log.go b/log.go index 9238468fb931..a637d5193525 100644 --- a/log.go +++ b/log.go @@ -1,6 +1,7 @@ package raft import ( + "fmt" "time" metrics "github.com/armon/go-metrics" @@ -39,6 +40,26 @@ const ( LogConfiguration ) +// String returns LogType as a human readable string. +func (lt LogType) String() string { + switch lt { + case LogCommand: + return "LogCommand" + case LogNoop: + return "LogNoop" + case LogAddPeerDeprecated: + return "LogAddPeerDeprecated" + case LogRemovePeerDeprecated: + return "LogRemovePeerDeprecated" + case LogBarrier: + return "LogBarrier" + case LogConfiguration: + return "LogConfiguration" + default: + return fmt.Sprintf("%d", lt) + } +} + // Log entries are replicated to all members of the Raft cluster // and form the heart of the replicated state machine. type Log struct {