代码拉取完成,页面将自动刷新
package harvester
import (
"regexp"
"time"
"github.com/elastic/beats/filebeat/harvester/processor"
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/logp"
)
// readLine reads a full line into buffer and returns it.
// In case of partial lines, readLine does return and error and en empty string
// This could potentialy be improved / replaced by https://github.com/elastic/beats/libbeat/tree/master/common/streambuf
func readLine(reader processor.LineProcessor) (time.Time, string, int, common.MapStr, error) {
l, err := reader.Next()
// Full line read to be returned
if l.Bytes != 0 && err == nil {
return l.Ts, string(l.Content), l.Bytes, l.Fields, err
}
return time.Time{}, "", 0, nil, err
}
// InitRegexps initializes a list of compiled regular expressions.
func InitRegexps(exprs []string) ([]*regexp.Regexp, error) {
result := []*regexp.Regexp{}
for _, exp := range exprs {
rexp, err := regexp.CompilePOSIX(exp)
if err != nil {
logp.Err("Fail to compile the regexp %s: %s", exp, err)
return nil, err
}
result = append(result, rexp)
}
return result, nil
}
// MatchAnyRegexps checks if the text matches any of the regular expressions
func MatchAnyRegexps(regexps []*regexp.Regexp, text string) bool {
for _, rexp := range regexps {
if rexp.MatchString(text) {
return true
}
}
return false
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。