@@ -171,12 +171,14 @@ func (r *Rule) Evaluate(phase types.RulePhase, tx plugintypes.TransactionState,
171
171
// collectiveMatchedValues lives across recursive calls of doEvaluate
172
172
var collectiveMatchedValues []types.MatchData
173
173
174
- var logger debuglog. Logger
174
+ logger := tx . DebugLogger ()
175
175
176
- if r .ID_ == noID {
177
- logger = tx .DebugLogger ().With (debuglog .Str ("rule_ref" , fmt .Sprintf ("%s#L%d" , r .File_ , r .Line_ )))
178
- } else {
179
- logger = tx .DebugLogger ().With (debuglog .Int ("rule_id" , r .ID_ ))
176
+ if logger .Debug ().IsEnabled () {
177
+ if r .ID_ == noID {
178
+ logger = logger .With (debuglog .Str ("rule_ref" , fmt .Sprintf ("%s#L%d" , r .File_ , r .Line_ )))
179
+ } else {
180
+ logger = logger .With (debuglog .Int ("rule_id" , r .ID_ ))
181
+ }
180
182
}
181
183
182
184
r .doEvaluate (logger , phase , tx .(* Transaction ), & collectiveMatchedValues , chainLevelZero , cache )
@@ -245,7 +247,10 @@ func (r *Rule) doEvaluate(logger debuglog.Logger, phase types.RulePhase, tx *Tra
245
247
246
248
values = tx .GetField (v )
247
249
248
- vLog := logger .With (debuglog .Str ("variable" , v .Variable .Name ()))
250
+ vLog := logger
251
+ if logger .Debug ().IsEnabled () {
252
+ vLog = logger .With (debuglog .Str ("variable" , v .Variable .Name ()))
253
+ }
249
254
vLog .Debug ().Msg ("Expanding arguments for rule" )
250
255
251
256
for i , arg := range values {
0 commit comments