Jelajahi Sumber

增加函数清理,特殊符号清理日志

maxiaoshan 6 tahun lalu
induk
melakukan
84c1ea884c
1 mengubah file dengan 45 tambahan dan 2 penghapusan
  1. 45 2
      src/jy/extract/extract.go

+ 45 - 2
src/jy/extract/extract.go

@@ -439,17 +439,22 @@ func (e *ExtractTask) ExtractDetail(j *ju.Job) {
 				cfn := e.ClearFn[key]
 				lockclear.Unlock()
 				data := clear.DoClearFn(cfn, []interface{}{v.Value, j.Content})
+				before, _ := v.Value.(string)
 				v.Value = data[0]
+				BeforeAddClearFnLog("clearcfn", "函数清理", j.SourceMid, before, "clear_cfn", v, e)
+				//添加行数清理的日志
 				//清理特殊符号
 				lockclear.Lock()
-				if clear.AsyField[key] != nil || clear.SymField[key] != nil ||
-					clear.MesField[key] != nil {
+				if clear.AsyField[key] != nil || clear.SymField[key] != nil || clear.MesField[key] != nil {
 					text := qu.ObjToString(v.Value)
+					before = text
 					text = clear.OtherClean(key, text)
 					if text != "" {
 						v.Value = text
 					}
+					BeforeAddClearFnLog("clearsymbol", "特殊符号清理", j.SourceMid, before, "clear_symbol", v, e)
 				}
+				//AddClearFnLog("clearfn", j.SourceMid, v.Value, extinfo, v.Code, "函数清理", key, e.TaskInfo)
 				lockclear.Unlock()
 			}
 		}
@@ -1107,6 +1112,44 @@ func AddExtLog(ftype, sid string, before interface{}, extinfo interface{}, v *Re
 	ExtLogs[t] = append(ExtLogs[t], logdata)
 	lock.Unlock()
 }
+func BeforeAddClearFnLog(ftype, name, sid, before, matchtype string, ext *ju.ExtField, e *ExtractTask) {
+	exts := []map[string]interface{}{}
+	exts = append(exts, map[string]interface{}{
+		"field":     ext.Field,
+		"code":      ext.Code,
+		"type":      ftype,
+		"matchtype": matchtype,
+		"extfrom":   ext.ExtFrom,
+		"value":     ext.Value,
+	})
+	extinfo := map[string]interface{}{
+		ext.Field: exts,
+	}
+	AddClearFnLog(ftype, sid, before, extinfo, ext.Code, name, ext.Field, e.TaskInfo)
+}
+func AddClearFnLog(ftype, sid string, before interface{}, extinfo interface{}, code, name, field string, t *TaskInfo) {
+	defer qu.Catch()
+	if !t.IsEtxLog {
+		return
+	}
+	logdata := map[string]interface{}{
+		"code":       code,
+		"name":       name,
+		"type":       ftype,
+		"ruletext":   "",
+		"islua":      false,
+		"field":      field,
+		"version":    t.Version,
+		"taskname":   t.Name,
+		"before":     before,
+		"extinfo":    extinfo,
+		"sid":        sid,
+		"comeintime": time.Now().Unix(),
+	}
+	lock.Lock()
+	ExtLogs[t] = append(ExtLogs[t], logdata)
+	lock.Unlock()
+}
 
 //保存抽取日志
 func SaveExtLog() {