From f3dd066f0141ebbe10d275243bfb27cd496bfe90 Mon Sep 17 00:00:00 2001 From: "zhangxu19830126@gmail.com" Date: Tue, 5 Nov 2019 06:30:59 +0800 Subject: [PATCH] Rename log method --- election.go | 10 +++++----- local.go | 4 ++-- log.go | 8 ++++---- peer_replica.go | 2 +- peer_transport.go | 2 +- prophet_coordinator.go | 2 +- prophet_etcd.go | 4 ++-- prophet_rpc.go | 4 ++-- store_etcd.go | 2 +- watcher_client.go | 2 +- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/election.go b/election.go index 2bf0fa2..a92b552 100644 --- a/election.go +++ b/election.go @@ -113,11 +113,11 @@ func (e *elector) ElectionLoop(ctx context.Context, group uint64, current string if current != "" && leader == current { // oh, we are already leader, we may meet something wrong // in previous campaignLeader. we can resign and campaign again. - log.Warnf("[group-%d]: leader is matched, resign and campaign again, leader %+v", + log.Warningf("[group-%d]: leader is matched, resign and campaign again, leader %+v", group, leader) if err = e.resignLeader(group, current); err != nil { - log.Warnf("[group-%d]: resign leader failure, leader peer %+v, errors:\n %+v", + log.Warningf("[group-%d]: resign leader failure, leader peer %+v, errors:\n %+v", group, leader, err) @@ -224,7 +224,7 @@ func (e *elector) campaignLeader(stopCtx context.Context, group uint64, leader s cancel() if cost := time.Now().Sub(start); cost > DefaultSlowRequestTime { - log.Warnf("lessor grants too slow, cost=<%s>", cost) + log.Warningf("lessor grants too slow, cost=<%s>", cost) } if err != nil { return err @@ -440,7 +440,7 @@ func (e *elector) get(key string, opts ...clientv3.OpOption) (*clientv3.GetRespo } if cost := time.Since(start); cost > DefaultSlowRequestTime { - log.Warnf("read option is too slow, key=<%s>, cost=<%d>", + log.Warningf("read option is too slow, key=<%s>, cost=<%d>", key, cost) } @@ -496,7 +496,7 @@ func (t *slowLogTxn) Commit() (*clientv3.TxnResponse, error) { cost := time.Now().Sub(start) if cost > DefaultSlowRequestTime { - log.Warnf("txn runs too slow, resp=<%+v> cost=<%s> errors:\n %+v", + log.Warningf("txn runs too slow, resp=<%+v> cost=<%s> errors:\n %+v", resp, cost, err) diff --git a/local.go b/local.go index 04268a7..a0f2342 100644 --- a/local.go +++ b/local.go @@ -150,7 +150,7 @@ type defaultLocalStore struct { func (ls *defaultLocalStore) BootstrapCluster(initResources ...Resource) { if len(initResources) == 0 { - log.Warnf("init with empty resources") + log.Warningf("init with empty resources") } data, err := ls.db.get(containerKey) @@ -204,7 +204,7 @@ func (ls *defaultLocalStore) BootstrapCluster(initResources ...Resource) { log.Fatal("bootstrap cluster failed with %+v", err) } - log.Warnf("bootstrap cluster failed with %+v", err) + log.Warningf("bootstrap cluster failed with %+v", err) } if !ok { log.Info("the cluster is already bootstrapped") diff --git a/log.go b/log.go index 89c90b5..3c411d6 100644 --- a/log.go +++ b/log.go @@ -14,8 +14,8 @@ type Logger interface { Infof(format string, v ...interface{}) Debug(v ...interface{}) Debugf(format string, v ...interface{}) - Warn(v ...interface{}) - Warnf(format string, v ...interface{}) + Warning(v ...interface{}) + Warningf(format string, v ...interface{}) Error(v ...interface{}) Errorf(format string, v ...interface{}) Fatal(v ...interface{}) @@ -39,11 +39,11 @@ func (l *emptyLog) Debugf(format string, v ...interface{}) { stdLog.Printf(format, v...) } -func (l *emptyLog) Warn(v ...interface{}) { +func (l *emptyLog) Warning(v ...interface{}) { stdLog.Print(v...) } -func (l *emptyLog) Warnf(format string, v ...interface{}) { +func (l *emptyLog) Warningf(format string, v ...interface{}) { stdLog.Printf(format, v...) } diff --git a/peer_replica.go b/peer_replica.go index 4a3cfea..d8e8f24 100644 --- a/peer_replica.go +++ b/peer_replica.go @@ -330,7 +330,7 @@ func (pr *PeerReplica) becomeFollower() { err := pr.cmds.Put(c) if err != nil { - log.Warnf("%s add become follower event failed with %+v", + log.Warningf("%s add become follower event failed with %+v", pr.tag, err) c.cb(nil, nil) diff --git a/peer_transport.go b/peer_transport.go index f1f73d3..6d27cce 100644 --- a/peer_transport.go +++ b/peer_transport.go @@ -208,7 +208,7 @@ func (t *defaultReplicaTransport) doConnection(session goetty.IOSession) error { if err == io.EOF { log.Infof("closed by %s", remoteIP) } else { - log.Warnf("read error from conn-%s, errors:\n%+v", + log.Warningf("read error from conn-%s, errors:\n%+v", remoteIP, err) } diff --git a/prophet_coordinator.go b/prophet_coordinator.go index e64a987..5028be7 100644 --- a/prophet_coordinator.go +++ b/prophet_coordinator.go @@ -38,7 +38,7 @@ func newCoordinator(cfg *Cfg, runner *Runner, rt *Runtime) *Coordinator { func (c *Coordinator) start() { if c.running { - log.Warnf("prophet: coordinator is already started.") + log.Warningf("prophet: coordinator is already started.") return } diff --git a/prophet_etcd.go b/prophet_etcd.go index 33e4041..d43c71f 100644 --- a/prophet_etcd.go +++ b/prophet_etcd.go @@ -237,7 +237,7 @@ func endpointStatus(cfg *embed.Config, c *clientv3.Client) (*clientv3.StatusResp cancel() if cost := time.Since(start); cost > DefaultSlowRequestTime { - log.Warnf("prophet: check etcd status failed, endpoint=<%s> resp=<%+v> cost<%s> errors:\n %+v", + log.Warningf("prophet: check etcd status failed, endpoint=<%s> resp=<%+v> cost<%s> errors:\n %+v", endpoint, resp, cost, @@ -289,7 +289,7 @@ func checkClusterID(localClusterID types.ID, um types.URLsMap) error { trp.CloseIdleConnections() if gerr != nil { // Do not return error, because other members may be not ready. - log.Warnf("bootstrap: check etcd embed, may be member is not ready, member=<%s>", + log.Warningf("bootstrap: check etcd embed, may be member is not ready, member=<%s>", u) continue } diff --git a/prophet_rpc.go b/prophet_rpc.go index 53ae4aa..562124e 100644 --- a/prophet_rpc.go +++ b/prophet_rpc.go @@ -77,7 +77,7 @@ func (rpc *simpleRPC) AllocID() (uint64, error) { if rsp, ok := value.(*allocIDRsp); ok { if rpc.notLeaderErr(rsp.Err) { - log.Warnf("prophet: alloc id failed with not leader, retry") + log.Warningf("prophet: alloc id failed with not leader, retry") rpc.wait(conn) break } @@ -115,7 +115,7 @@ func (rpc *simpleRPC) AskSplit(res Resource) (uint64, []uint64, error) { if rsp, ok := value.(*askSplitRsp); ok { if rpc.notLeaderErr(rsp.Err) { - log.Warnf("prophet: ask split failed with not leader, retry") + log.Warningf("prophet: ask split failed with not leader, retry") rpc.wait(conn) break } diff --git a/store_etcd.go b/store_etcd.go index 15903d9..56d0b2e 100644 --- a/store_etcd.go +++ b/store_etcd.go @@ -411,7 +411,7 @@ func (s *etcdStore) get(key string, opts ...clientv3.OpOption) (*clientv3.GetRes } if cost := time.Since(start); cost > DefaultSlowRequestTime { - log.Warnf("prophet: read option is too slow, key=<%s>, cost=<%d>", + log.Warningf("prophet: read option is too slow, key=<%s>, cost=<%d>", key, cost) } diff --git a/watcher_client.go b/watcher_client.go index 6e9c242..8752ecc 100644 --- a/watcher_client.go +++ b/watcher_client.go @@ -138,7 +138,7 @@ func (w *Watcher) startReadLoop() { log.Infof("%d, %d", expectSeq, evt.Seq) // we lost some event notify, close the conection, and retry if expectSeq != evt.Seq { - log.Warnf("prophet: watch lost some event notify, expect seq %d, but %d, close and retry", + log.Warningf("prophet: watch lost some event notify, expect seq %d, but %d, close and retry", expectSeq, evt.Seq) w.conn.Close()