Skip to content

Commit

Permalink
Rename log method
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangxu19830126 committed Nov 4, 2019
1 parent 8ce9c76 commit f3dd066
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 20 deletions.
10 changes: 5 additions & 5 deletions election.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions local.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down
8 changes: 4 additions & 4 deletions log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
Expand All @@ -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...)
}

Expand Down
2 changes: 1 addition & 1 deletion peer_replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion peer_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion prophet_coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions prophet_etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions prophet_rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion store_etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion watcher_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit f3dd066

Please sign in to comment.