Skip to content

Commit 3221f7b

Browse files
authored
parser: avoid calling spew unless trace (#4156)
1 parent 5b1f5eb commit 3221f7b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pkg/parser/node.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,11 +400,12 @@ func (n *Node) process(p *pipeline.Event, ctx UnixParserCtx, expressionEnv map[s
400400
return nodeState, nil
401401
}
402402

403+
var dumpr = spew.ConfigState{MaxDepth: 1, DisablePointerAddresses: true}
404+
403405
func (n *Node) compile(pctx *UnixParserCtx, ectx EnricherCtx) error {
404406
var err error
405407

406408
valid := false
407-
dumpr := spew.ConfigState{MaxDepth: 1, DisablePointerAddresses: true}
408409

409410
n.rn = seed.Generate()
410411

@@ -428,7 +429,9 @@ func (n *Node) compile(pctx *UnixParserCtx, ectx EnricherCtx) error {
428429
/* display info about top-level nodes, they should be the only one with explicit stage name ?*/
429430
n.Logger = n.Logger.WithFields(log.Fields{"stage": n.Stage, "name": n.Name})
430431

431-
n.Logger.Tracef("Compiling: %s", dumpr.Sdump(n))
432+
if n.Logger.Logger.IsLevelEnabled(log.TraceLevel) {
433+
n.Logger.Tracef("Compiling: %s", dumpr.Sdump(n))
434+
}
432435

433436
// compile filter if present
434437
if n.Filter != "" {

0 commit comments

Comments
 (0)