search key support multiple value

This commit is contained in:
ehlxr 2019-11-28 17:01:42 +08:00
parent e6869549e5
commit 17a4513c01
2 changed files with 10 additions and 7 deletions

View File

@ -72,7 +72,9 @@ func tailFile() {
text = strings.ToLower(text)
}
if ok, _ := regexp.Match(pkg.Opts.KeyWord, []byte(text)); ok {
keys := strings.Split(pkg.Opts.KeyWord, ",")
for _, key := range keys {
if ok, _ := regexp.Match(strings.TrimSpace(key), []byte(text)); ok {
if limiter.IsAvailable() {
sendMsg(line.Text)
} else {
@ -81,4 +83,5 @@ func tailFile() {
}
}
}
}
}

View File

@ -10,7 +10,7 @@ var (
Opts struct {
AppName string `short:"n" long:"monitor-app-name" env:"MONITOR_APP_NAME" description:"The name of the application being monitored, which will be added to the content before"`
File string `short:"f" long:"monitor-file" env:"MONITOR_FILE" description:"The file to be monitored" required:"true"`
KeyWord string `short:"k" long:"search-keyword" env:"SEARCH_KEYWORD" description:"Keyword to be search for" default:"ERRO"`
KeyWord string `short:"k" long:"search-keyword" env:"SEARCH_KEYWORD" description:"Keyword to be search for, Multiple values separated by ','" default:"ERRO"`
KeyWordIgnoreCase bool `short:"c" long:"keyword-case-sensitive" env:"KEYWORD_IGNORE_CASE" description:"Whether Keyword ignore case"`
Version bool `short:"v" long:"version" description:"Show version info"`
Robot Robot `group:"DingTalk Robot Options" namespace:"robot" env-namespace:"ROBOT" `