优化日志代码
This commit is contained in:
parent
b4a3b8301e
commit
db0a7225fa
@ -1,12 +1,5 @@
|
||||
package buried
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
)
|
||||
|
||||
const (
|
||||
//创号后入录数据
|
||||
rtype1 = 1
|
||||
@ -31,53 +24,3 @@ const (
|
||||
lte = "lte" // <=
|
||||
ne = "ne" // !=
|
||||
)
|
||||
|
||||
//判断埋点数据的有效性
|
||||
func checkburied(buried *pb.BuriedParam, bconf *cfg.GameBuriedTypeData, conf *cfg.GameBuriedCondiData) (efficient bool) {
|
||||
if !(len(buried.Filter) == len(conf.Filter) && len(bconf.Filter) == len(conf.Filter)) {
|
||||
log.Error("校验埋点错误!", log.Field{Key: "buried", Value: buried}, log.Field{Key: "conf", Value: conf})
|
||||
return
|
||||
}
|
||||
for i, v := range conf.Filter {
|
||||
efficient = false
|
||||
value := buried.Filter[i]
|
||||
symbol := bconf.Filter[i]
|
||||
target := conf.Filter[i]
|
||||
switch symbol {
|
||||
case eq: //==
|
||||
if value == target {
|
||||
efficient = true
|
||||
}
|
||||
case gt: //>
|
||||
if value > target {
|
||||
efficient = true
|
||||
}
|
||||
case gte: //>=
|
||||
if value >= target {
|
||||
efficient = true
|
||||
}
|
||||
case lt: //<
|
||||
if value < target {
|
||||
efficient = true
|
||||
}
|
||||
case lte: //<=
|
||||
if value <= target {
|
||||
efficient = true
|
||||
}
|
||||
case ne: //!=
|
||||
if value != target {
|
||||
efficient = true
|
||||
}
|
||||
default:
|
||||
log.Error("校验埋点配置错误!", log.Field{Key: "不存在的比较符号", Value: v}, log.Field{Key: "buried", Value: buried}, log.Field{Key: "conf", Value: conf})
|
||||
return
|
||||
}
|
||||
|
||||
if !efficient { //校验不过
|
||||
log.Debug("校验不通!", log.Field{Key: "埋点id", Value: buried.TaskType}, log.Field{Key: "条件id", Value: conf.Id}, log.Field{Key: "判断公式", Value: fmt.Sprintf("%d %s %d", value, symbol, target)})
|
||||
return
|
||||
}
|
||||
}
|
||||
efficient = true
|
||||
return
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ func (this *Buried) trigger(uid string, burieds ...*pb.BuriedParam) {
|
||||
continue
|
||||
}
|
||||
for _, cond := range conds {
|
||||
if checkburied(buried, bconf, cond) { //判断此埋点数据是否有效
|
||||
if this.checkburied(buried, bconf, cond) { //判断此埋点数据是否有效
|
||||
if _, ok := pass[buried]; !ok {
|
||||
pass[buried] = make([]*cfg.GameBuriedCondiData, 0)
|
||||
}
|
||||
@ -384,3 +384,53 @@ func (this *Buried) updateAndCheckBuried(bconf *cfg.GameBuriedTypeData, bdata *p
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//判断埋点数据的有效性
|
||||
func (this *Buried) checkburied(buried *pb.BuriedParam, bconf *cfg.GameBuriedTypeData, conf *cfg.GameBuriedCondiData) (efficient bool) {
|
||||
if !(len(buried.Filter) == len(conf.Filter) && len(bconf.Filter) == len(conf.Filter)) {
|
||||
this.Error("校验埋点错误!", log.Field{Key: "buried", Value: buried}, log.Field{Key: "conf", Value: conf})
|
||||
return
|
||||
}
|
||||
for i, v := range conf.Filter {
|
||||
efficient = false
|
||||
value := buried.Filter[i]
|
||||
symbol := bconf.Filter[i]
|
||||
target := conf.Filter[i]
|
||||
switch symbol {
|
||||
case eq: //==
|
||||
if value == target {
|
||||
efficient = true
|
||||
}
|
||||
case gt: //>
|
||||
if value > target {
|
||||
efficient = true
|
||||
}
|
||||
case gte: //>=
|
||||
if value >= target {
|
||||
efficient = true
|
||||
}
|
||||
case lt: //<
|
||||
if value < target {
|
||||
efficient = true
|
||||
}
|
||||
case lte: //<=
|
||||
if value <= target {
|
||||
efficient = true
|
||||
}
|
||||
case ne: //!=
|
||||
if value != target {
|
||||
efficient = true
|
||||
}
|
||||
default:
|
||||
this.Error("校验埋点配置错误!", log.Field{Key: "不存在的比较符号", Value: v}, log.Field{Key: "buried", Value: buried}, log.Field{Key: "conf", Value: conf})
|
||||
return
|
||||
}
|
||||
|
||||
if !efficient { //校验不过
|
||||
this.Debug("校验不通!", log.Field{Key: "埋点id", Value: buried.TaskType}, log.Field{Key: "条件id", Value: conf.Id}, log.Field{Key: "判断公式", Value: fmt.Sprintf("%d %s %d", value, symbol, target)})
|
||||
return
|
||||
}
|
||||
}
|
||||
efficient = true
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user