pkg/logutil: change "NewRaftLogger" function signature
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
This commit is contained in:
@ -15,6 +15,8 @@
|
|||||||
package logutil
|
package logutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
"github.com/coreos/etcd/raft"
|
"github.com/coreos/etcd/raft"
|
||||||
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
@ -22,7 +24,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// NewRaftLogger converts "*zap.Logger" to "raft.Logger".
|
// NewRaftLogger converts "*zap.Logger" to "raft.Logger".
|
||||||
func NewRaftLogger(lcfg zap.Config) (raft.Logger, error) {
|
func NewRaftLogger(lcfg *zap.Config) (raft.Logger, error) {
|
||||||
|
if lcfg == nil {
|
||||||
|
return nil, errors.New("nil zap.Config")
|
||||||
|
}
|
||||||
lg, err := lcfg.Build(zap.AddCallerSkip(1)) // to annotate caller outside of "logutil"
|
lg, err := lcfg.Build(zap.AddCallerSkip(1)) // to annotate caller outside of "logutil"
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -32,7 +32,7 @@ func TestNewRaftLogger(t *testing.T) {
|
|||||||
logPath := filepath.Join(os.TempDir(), fmt.Sprintf("test-log-%d", time.Now().UnixNano()))
|
logPath := filepath.Join(os.TempDir(), fmt.Sprintf("test-log-%d", time.Now().UnixNano()))
|
||||||
defer os.RemoveAll(logPath)
|
defer os.RemoveAll(logPath)
|
||||||
|
|
||||||
lcfg := zap.Config{
|
lcfg := &zap.Config{
|
||||||
Level: zap.NewAtomicLevelAt(zap.DebugLevel),
|
Level: zap.NewAtomicLevelAt(zap.DebugLevel),
|
||||||
Development: false,
|
Development: false,
|
||||||
Sampling: &zap.SamplingConfig{
|
Sampling: &zap.SamplingConfig{
|
||||||
|
Reference in New Issue
Block a user