Skip to content

Commit

Permalink
Merge pull request #9746 from gyuho/raft-logger
Browse files Browse the repository at this point in the history
etcdserver: set default Raft logger with zap.Logger
  • Loading branch information
gyuho authored May 18, 2018
2 parents 1a399bd + 58ae15b commit 955fd99
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions etcdserver/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"github.com/coreos/etcd/wal"
"github.com/coreos/etcd/wal/walpb"

"github.com/coreos/pkg/capnslog"
"go.uber.org/zap"
)

Expand All @@ -59,7 +58,25 @@ var (
)

func init() {
raft.SetLogger(capnslog.NewPackageLogger("github.com/coreos/etcd", "raft"))
lcfg := &zap.Config{
Level: zap.NewAtomicLevelAt(zap.InfoLevel),
Development: false,
Sampling: &zap.SamplingConfig{
Initial: 100,
Thereafter: 100,
},
Encoding: "json",
EncoderConfig: zap.NewProductionEncoderConfig(),

OutputPaths: []string{"stderr"},
ErrorOutputPaths: []string{"stderr"},
}
lg, err := logutil.NewRaftLogger(lcfg)
if err != nil {
log.Fatalf("cannot create raft logger %v", err)
}
raft.SetLogger(lg)

expvar.Publish("raft.status", expvar.Func(func() interface{} {
raftStatusMu.Lock()
defer raftStatusMu.Unlock()
Expand Down

0 comments on commit 955fd99

Please sign in to comment.