log for etcd

pull/236/head
skiffer-git 2 years ago
parent f1b5f56294
commit 9443ed5d49

@ -83,9 +83,9 @@ func RegisterEtcd(schema, etcdAddr, myHost string, myPort int, serviceName strin
select { select {
case pv, ok := <-kresp: case pv, ok := <-kresp:
if ok == true { if ok == true {
log.Debug(operationID, "KeepAlive kresp ok", pv) log.Debug(operationID, "KeepAlive kresp ok", pv, args)
} else { } else {
log.Error(operationID, "KeepAlive kresp failed", pv) log.Error(operationID, "KeepAlive kresp failed ", pv, args)
t := time.NewTicker(time.Duration(ttl/2) * time.Second) t := time.NewTicker(time.Duration(ttl/2) * time.Second)
for { for {
select { select {
@ -94,15 +94,15 @@ func RegisterEtcd(schema, etcdAddr, myHost string, myPort int, serviceName strin
ctx, _ := context.WithCancel(context.Background()) ctx, _ := context.WithCancel(context.Background())
resp, err := cli.Grant(ctx, int64(ttl)) resp, err := cli.Grant(ctx, int64(ttl))
if err != nil { if err != nil {
log.Error(operationID, "Grant failed ", err.Error()) log.Error(operationID, "Grant failed ", err.Error(), args)
continue continue
} }
if _, err := cli.Put(ctx, serviceKey, serviceValue, clientv3.WithLease(resp.ID)); err != nil { if _, err := cli.Put(ctx, serviceKey, serviceValue, clientv3.WithLease(resp.ID)); err != nil {
log.Error(operationID, "etcd Put failed ", err.Error(), args, "resp ID: ", resp.ID) log.Error(operationID, "etcd Put failed ", err.Error(), args, " resp ID: ", resp.ID)
continue continue
} else { } else {
log.Info(operationID, "etcd Put ok ", args, "resp ID: ", resp.ID) log.Info(operationID, "etcd Put ok ", args, " resp ID: ", resp.ID)
} }
} }
} }

Loading…
Cancel
Save