From 426ba9d7e1273f52e0a704ca55a875b3d9439097 Mon Sep 17 00:00:00 2001 From: Dennis Haney Date: Wed, 30 Oct 2024 19:55:02 +0700 Subject: [PATCH] fix: add check for log level --- plan/policy.go | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/plan/policy.go b/plan/policy.go index e02ae49eed..6898b846ee 100644 --- a/plan/policy.go +++ b/plan/policy.go @@ -45,8 +45,10 @@ type UpsertOnlyPolicy struct{} // Apply applies the upsert-only policy which strips out any deletions. func (p *UpsertOnlyPolicy) Apply(changes *Changes) *Changes { - for _, ep := range changes.Delete { + if log.GetLevel() == log.DebugLevel { + for _, ep := range changes.Delete { log.Debugf(`Skipping deletion of endpoint %v due to "upsert-only" policy`, ep) + } } return &Changes{ Create: changes.Create, @@ -60,14 +62,16 @@ type CreateOnlyPolicy struct{} // Apply applies the create-only policy which strips out updates and deletions. func (p *CreateOnlyPolicy) Apply(changes *Changes) *Changes { - for _, ep := range changes.Delete { - log.Debugf(`Skipping deletion of endpoint %v due to "create-only" policy`, ep) - } - for _, ep := range changes.UpdateOld { - log.Debugf(`Skipping update-old of endpoint %v due to "create-only" policy`, ep) - } - for _, ep := range changes.UpdateNew { - log.Debugf(`Skipping update-new of endpoint %v due to "create-only" policy`, ep) + if log.GetLevel() == log.DebugLevel { + for _, ep := range changes.Delete { + log.Debugf(`Skipping deletion of endpoint %v due to "create-only" policy`, ep) + } + for _, ep := range changes.UpdateOld { + log.Debugf(`Skipping update-old of endpoint %v due to "create-only" policy`, ep) + } + for _, ep := range changes.UpdateNew { + log.Debugf(`Skipping update-new of endpoint %v due to "create-only" policy`, ep) + } } return &Changes{ Create: changes.Create,