Fix logger format bug (#99)

This commit is contained in:
陈键冬 2020-04-19 21:05:33 +08:00 committed by GitHub
parent 8790094b15
commit 747c18a076
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 10 deletions

View File

@ -66,7 +66,7 @@ func GetByID(id int64) (*stra.Strategy, error) {
st, ok := globalStrategy[id]
if !ok {
return nil, fmt.Errorf("ID : %d is not exists in global Cache")
return nil, fmt.Errorf("ID : %d is not exists in global Cache", id)
}
return st, nil

View File

@ -69,19 +69,19 @@ func EntityNumMetrics() []*dataobj.MetricValue {
L := strings.Fields(data)
if len(L) < 5 {
logger.Errorf("get entity num err:", data)
logger.Errorf("get entity num err: %v", data)
return nil
}
arr := strings.Split(L[3], "/")
if len(arr) != 2 {
logger.Errorf("get entity num err:", data)
logger.Errorf("get entity num err: %v", data)
return nil
}
num, err := strconv.ParseFloat(arr[1], 64)
if err != nil {
logger.Errorf("get entity num err:", err)
logger.Errorf("get entity num err: %v", err)
return nil
}

View File

@ -95,7 +95,7 @@ func Judge(stra *model.Stra, exps []model.Exp, historyData []*dataobj.RRDData, f
if len(exps) == 1 {
bs, err := json.Marshal(history)
if err != nil {
logger.Error("Marshal history:%v err:%v", history, err)
logger.Errorf("Marshal history:%v err:%v", history, err)
}
event := &dataobj.Event{
ID: fmt.Sprintf("s_%d_%s", stra.Id, firstItem.PrimaryKey()),

View File

@ -62,14 +62,14 @@ func CleanStra() {
for _, stra := range list {
node, err := model.NodeGet("id", stra.Nid)
if err != nil {
logger.Warning("get node failed, node id: %v, err: %v", stra.Nid, err)
logger.Warningf("get node failed, node id: %d, err: %v", stra.Nid, err)
continue
}
if node == nil {
logger.Infof("delete stra:%d", stra.Id)
if err := model.StraDel(stra.Id); err != nil {
logger.Warning("delete stra: %d, err: %v", stra.Id, err)
logger.Warningf("delete stra: %d, err: %v", stra.Id, err)
}
}
}

View File

@ -90,7 +90,7 @@ func syncCollects() {
ports, err := model.GetPortCollects()
if err != nil {
logger.Warningf("get port collects err:%v %v", err)
logger.Warningf("get port collects err:%v", err)
}
for _, p := range ports {
@ -120,7 +120,7 @@ func syncCollects() {
procs, err := model.GetProcCollects()
if err != nil {
logger.Warningf("get port collects err:%v %v", err)
logger.Warningf("get port collects err:%v", err)
}
for _, p := range procs {
@ -149,7 +149,7 @@ func syncCollects() {
logConfigs, err := model.GetLogCollects()
if err != nil {
logger.Warningf("get log collects err:%v %v", err)
logger.Warningf("get log collects err:%v", err)
}
for _, l := range logConfigs {