@@ -32,7 +32,7 @@ type Statement[K any] struct {
3232func (s * Statement [K ]) Execute (ctx context.Context , tCtx K ) (any , bool , error ) {
3333 condition , err := s .condition .Eval (ctx , tCtx )
3434 defer func () {
35- if s .telemetrySettings .Logger != nil {
35+ if s .telemetrySettings .Logger . Core (). Enabled ( zap . DebugLevel ) {
3636 s .telemetrySettings .Logger .Debug ("TransformContext after statement execution" , zap .String ("statement" , s .origText ), zap .Bool ("condition matched" , condition ), zap .Any ("TransformContext" , tCtx ))
3737 }
3838 }()
@@ -381,7 +381,9 @@ func NewStatementSequence[K any](statements []*Statement[K], telemetrySettings c
381381// When the ErrorMode of the StatementSequence is `ignore`, errors are logged and execution continues to the next statement.
382382// When the ErrorMode of the StatementSequence is `silent`, errors are not logged and execution continues to the next statement.
383383func (s * StatementSequence [K ]) Execute (ctx context.Context , tCtx K ) error {
384- s .telemetrySettings .Logger .Debug ("initial TransformContext before executing StatementSequence" , zap .Any ("TransformContext" , tCtx ))
384+ if s .telemetrySettings .Logger .Core ().Enabled (zap .DebugLevel ) {
385+ s .telemetrySettings .Logger .Debug ("initial TransformContext before executing StatementSequence" , zap .Any ("TransformContext" , tCtx ))
386+ }
385387 for _ , statement := range s .statements {
386388 _ , _ , err := statement .Execute (ctx , tCtx )
387389 if err != nil {
@@ -454,7 +456,9 @@ func (c *ConditionSequence[K]) Eval(ctx context.Context, tCtx K) (bool, error) {
454456 var atLeastOneMatch bool
455457 for _ , condition := range c .conditions {
456458 match , err := condition .Eval (ctx , tCtx )
457- c .telemetrySettings .Logger .Debug ("condition evaluation result" , zap .String ("condition" , condition .origText ), zap .Bool ("match" , match ), zap .Any ("TransformContext" , tCtx ))
459+ if c .telemetrySettings .Logger .Core ().Enabled (zap .DebugLevel ) {
460+ c .telemetrySettings .Logger .Debug ("condition evaluation result" , zap .String ("condition" , condition .origText ), zap .Bool ("match" , match ), zap .Any ("TransformContext" , tCtx ))
461+ }
458462 if err != nil {
459463 if c .errorMode == PropagateError {
460464 err = fmt .Errorf ("failed to eval condition: %v, %w" , condition .origText , err )
0 commit comments