Skip to content

Commit

Permalink
etcdserver: set default Raft logger with zap.Logger
Browse files Browse the repository at this point in the history
Signed-off-by: Gyuho Lee <[email protected]>
  • Loading branch information
gyuho committed May 18, 2018
1 parent 1c904b1 commit 58ae15b
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 Down Expand Up @@ -66,7 +65,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 58ae15b

Please sign in to comment.