Skip to content

Commit

Permalink
*: update logs. (tikv#676)
Browse files Browse the repository at this point in the history
  • Loading branch information
disksing authored and siddontang committed Jul 10, 2017
1 parent e74a99e commit 52721bc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/logutil/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
)

const (
defaultLogTimeFormat = "2006/01/02 15:04:05"
defaultLogTimeFormat = "2006/01/02 15:04:05.000"
defaultLogMaxSize = 300 // MB
defaultLogFormat = "text"
defaultLogLevel = log.InfoLevel
Expand Down
2 changes: 1 addition & 1 deletion pkg/logutil/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

const (
logPattern = `\d\d\d\d/\d\d/\d\d \d\d:\d\d:\d\d ([\w_%!$@.,+~-]+|\\.)+:\d+: \[(fatal|error|warning|info|debug)\] .*?\n`
logPattern = `\d\d\d\d/\d\d/\d\d \d\d:\d\d:\d\d\.\d\d\d ([\w_%!$@.,+~-]+|\\.)+:\d+: \[(fatal|error|warning|info|debug)\] .*?\n`
)

func Test(t *testing.T) {
Expand Down
9 changes: 6 additions & 3 deletions server/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,16 @@ func (c *coordinator) addOperator(op Operator) bool {
defer c.Unlock()
regionID := op.GetRegionID()

log.Infof("[region %v] add operator: %+v", regionID, op)

if old, ok := c.operators[regionID]; ok {
if !isHigherPriorityOperator(op, old) {
log.Infof("[region %v] cancel add operator, old: %+v", regionID, old)
return false
}
log.Infof("[region %v] replace old operator: %+v", regionID, old)
old.SetState(OperatorReplaced)
c.removeOperatorLocked(old)
log.Infof("coordinator: add operator %+v with higher priority, remove operator: %+v", op, old)
}

c.histories.add(regionID, op)
Expand Down Expand Up @@ -495,14 +498,14 @@ func (s *heartbeatStreams) run() {
storeID := msg.GetTargetPeer().GetStoreId()
if stream, ok := s.streams[storeID]; ok {
if err := stream.Send(msg); err != nil {
log.Errorf("send heartbeat message fail: %v", err)
log.Errorf("[region %v] send heartbeat message fail: %v", msg.RegionId, err)
delete(s.streams, storeID)
regionHeartbeatCounter.WithLabelValues("push", "err")
} else {
regionHeartbeatCounter.WithLabelValues("push", "ok")
}
} else {
log.Debugf("heartbeat stream not found for store %v, skip send message", storeID)
log.Debugf("[region %v] heartbeat stream not found for store %v, skip send message", msg.RegionId, storeID)
regionHeartbeatCounter.WithLabelValues("push", "skip")
}
case <-s.ctx.Done():
Expand Down

0 comments on commit 52721bc

Please sign in to comment.