add more tests for pkg/parser (config loading) (#172)

This commit is contained in:
Thibault "bui" Koechlin 2020-08-05 11:20:03 +02:00 committed by GitHub
parent b10c7e9bef
commit 8128dcf61b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 66 additions and 4 deletions

View file

@ -404,10 +404,10 @@ func (n *Node) compile(pctx *UnixParserCtx) error {
n.logger.Debugf("+ Regexp Compilation '%s'", n.Grok.RegexpName)
n.Grok.RunTimeRegexp, err = pctx.Grok.Get(n.Grok.RegexpName)
if err != nil {
n.logger.Fatalf("Unable to find grok '%s' : %v\n", n.Grok.RegexpName, err)
return fmt.Errorf("Unable to find grok '%s' : %v", n.Grok.RegexpName, err)
}
if n.Grok.RunTimeRegexp == nil {
n.logger.Fatalf("Didn't find regexp : %s", n.Grok.RegexpName)
return fmt.Errorf("Empty grok '%s'", n.Grok.RegexpName)
}
n.logger.Debugf("%s regexp: %s", n.Grok.RegexpName, n.Grok.RunTimeRegexp.Regexp.String())
valid = true
@ -415,11 +415,11 @@ func (n *Node) compile(pctx *UnixParserCtx) error {
//n.logger.Debugf("+ Regexp Compilation '%s'", n.Grok.RegexpValue)
n.Grok.RunTimeRegexp, err = pctx.Grok.Compile(n.Grok.RegexpValue)
if err != nil {
n.logger.Fatalf("Failed to compile grok '%s': %v\n", n.Grok.RegexpValue, err)
return fmt.Errorf("Failed to compile grok '%s': %v\n", n.Grok.RegexpValue, err)
}
if n.Grok.RunTimeRegexp == nil {
// We shouldn't be here because compilation succeeded, so regexp shouldn't be nil
n.logger.Fatalf("Grok compilation failure: %s", n.Grok.RegexpValue)
return fmt.Errorf("Grok compilation failure: %s", n.Grok.RegexpValue)
}
n.logger.Debugf("%s regexp : %s", n.Grok.RegexpValue, n.Grok.RunTimeRegexp.Regexp.String())
valid = true