Skip to content

Commit

Permalink
Add String() to LogType enum for easier debugging. (hashicorp#442)
Browse files Browse the repository at this point in the history
  • Loading branch information
icco committed Apr 13, 2021
1 parent fd170b8 commit 74683f6
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions log.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package raft

import (
"fmt"
"time"

metrics "github.com/armon/go-metrics"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 74683f6

Please sign in to comment.