client: Allow setting zap logger in config

This commit is contained in:
Marek Siarkowicz
2021-05-11 16:02:37 +02:00
parent 7ae55cf981
commit 06afe87b34
11 changed files with 26 additions and 26 deletions

View File

@@ -47,6 +47,7 @@ func Save(ctx context.Context, lg *zap.Logger, cfg clientv3.Config, dbPath strin
if lg == nil {
lg = zap.NewExample()
}
cfg.Logger = lg.Named("client")
if len(cfg.Endpoints) != 1 {
return fmt.Errorf("snapshot must be requested to one selected node, not multiple %v", cfg.Endpoints)
}
@@ -56,8 +57,6 @@ func Save(ctx context.Context, lg *zap.Logger, cfg clientv3.Config, dbPath strin
}
defer cli.Close()
cli = cli.WithLogger(lg.Named("client"))
partpath := dbPath + ".part"
defer os.RemoveAll(partpath)