unify loggers and improve the log message about groks when they're not called by name
This commit is contained in:
parent
a06f8373ae
commit
372d8680c3
|
@ -195,8 +195,11 @@ func LoadBucketDir(dir string, dataFolder string) ([]BucketFactory, chan types.E
|
|||
func LoadBucket(g *BucketFactory, dataFolder string) error {
|
||||
var err error
|
||||
if g.Debug {
|
||||
var clog = log.New()
|
||||
clog.SetFormatter(&log.TextFormatter{FullTimestamp: true})
|
||||
var clog = logrus.New()
|
||||
if types.ConfigureLogger(clog) != err {
|
||||
log.Fatalf("While creating bucket-specific logger : %s", err)
|
||||
}
|
||||
me
|
||||
clog.SetLevel(log.DebugLevel)
|
||||
g.logger = clog.WithFields(log.Fields{
|
||||
"cfg": g.BucketName,
|
||||
|
|
|
@ -253,10 +253,15 @@ func (n *Node) process(p *types.Event, ctx UnixParserCtx) (bool, error) {
|
|||
//return false, nil
|
||||
}
|
||||
}
|
||||
|
||||
var groklabel string
|
||||
if n.Grok.RegexpName == "" {
|
||||
groklabel = fmt.Sprintf("%5.5s...", n.Grok.RegexpValue)
|
||||
} else {
|
||||
groklabel = n.Grok.RegexpName
|
||||
}
|
||||
grok := n.Grok.RunTimeRegexp.Parse(gstr)
|
||||
if len(grok) > 0 {
|
||||
clog.Debugf("+ Grok '%s' returned %d entries to merge in Parsed", n.Grok.RegexpName, len(grok))
|
||||
clog.Debugf("+ Grok '%s' returned %d entries to merge in Parsed", groklabel, len(grok))
|
||||
//We managed to grok stuff, merged into parse
|
||||
for k, v := range grok {
|
||||
clog.Debugf("\t.Parsed['%s'] = '%s'", k, v)
|
||||
|
@ -269,7 +274,7 @@ func (n *Node) process(p *types.Event, ctx UnixParserCtx) (bool, error) {
|
|||
}
|
||||
} else {
|
||||
//grok failed, node failed
|
||||
clog.Debugf("+ Grok '%s' didn't return data on '%s'", n.Grok.RegexpName, gstr)
|
||||
clog.Debugf("+ Grok '%s' didn't return data on '%s'", groklabel, gstr)
|
||||
//clog.Tracef("on '%s'", gstr)
|
||||
NodeState = false
|
||||
}
|
||||
|
@ -337,6 +342,9 @@ func (n *Node) compile(pctx *UnixParserCtx) error {
|
|||
that will be used only for processing this node ;) */
|
||||
if n.Debug {
|
||||
var clog = logrus.New()
|
||||
if types.ConfigureLogger(clog) != err {
|
||||
log.Fatalf("While creating bucket-specific logger : %s", err)
|
||||
}
|
||||
clog.SetLevel(log.DebugLevel)
|
||||
n.logger = clog.WithFields(log.Fields{
|
||||
"id": n.rn,
|
||||
|
@ -412,6 +420,9 @@ func (n *Node) compile(pctx *UnixParserCtx) error {
|
|||
/* compile leafs if present */
|
||||
if len(n.SuccessNodes) > 0 {
|
||||
for idx := range n.SuccessNodes {
|
||||
if n.SuccessNodes[idx].Name == "" {
|
||||
n.SuccessNodes[idx].Name = fmt.Sprintf("child-%s", n.Name)
|
||||
}
|
||||
/*propagate debug/stats to child nodes*/
|
||||
if !n.SuccessNodes[idx].Debug && n.Debug {
|
||||
n.SuccessNodes[idx].Debug = true
|
||||
|
|
Loading…
Reference in a new issue