etcdserver: set default Raft logger with zap.Logger
@@ -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"
)
@@ -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()
