From 0e2c73a36d0e85f7f7479fc04da31c0dbb8e7373 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Thu, 23 Nov 2023 00:53:28 -0500 Subject: [PATCH] engine: resources: Reduce logging for file resource --- engine/resources/file.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/engine/resources/file.go b/engine/resources/file.go index bc24eec1..0eb9a42d 100644 --- a/engine/resources/file.go +++ b/engine/resources/file.go @@ -979,7 +979,9 @@ func (obj *FileRes) stateCheckApply(ctx context.Context, apply bool) (bool, erro // contentCheckApply performs a CheckApply for the file content. func (obj *FileRes) contentCheckApply(ctx context.Context, apply bool) (bool, error) { - obj.init.Logf("contentCheckApply(%t)", apply) + if obj.init.Debug { + obj.init.Logf("contentCheckApply(%t)", apply) + } // content is not defined, leave it alone... if obj.Content == nil { @@ -1002,7 +1004,9 @@ func (obj *FileRes) contentCheckApply(ctx context.Context, apply bool) (bool, er // sourceCheckApply performs a CheckApply for the file source. func (obj *FileRes) sourceCheckApply(ctx context.Context, apply bool) (bool, error) { - obj.init.Logf("sourceCheckApply(%t)", apply) + if obj.init.Debug { + obj.init.Logf("sourceCheckApply(%t)", apply) + } // source is not defined, leave it alone... if obj.Source == "" && !obj.Purge { @@ -1057,7 +1061,9 @@ func (obj *FileRes) sourceCheckApply(ctx context.Context, apply bool) (bool, err // fragmentsCheckApply performs a CheckApply for the file fragments. func (obj *FileRes) fragmentsCheckApply(ctx context.Context, apply bool) (bool, error) { - obj.init.Logf("fragmentsCheckApply(%t)", apply) + if obj.init.Debug { + obj.init.Logf("fragmentsCheckApply(%t)", apply) + } // fragments is not defined, leave it alone... if len(obj.Fragments) == 0 { @@ -1117,7 +1123,9 @@ func (obj *FileRes) fragmentsCheckApply(ctx context.Context, apply bool) (bool, // chownCheckApply performs a CheckApply for the file ownership. func (obj *FileRes) chownCheckApply(ctx context.Context, apply bool) (bool, error) { - obj.init.Logf("chownCheckApply(%t)", apply) + if obj.init.Debug { + obj.init.Logf("chownCheckApply(%t)", apply) + } if obj.Owner == "" && obj.Group == "" { // no owner or group specified, everything is ok @@ -1177,7 +1185,9 @@ func (obj *FileRes) chownCheckApply(ctx context.Context, apply bool) (bool, erro // chmodCheckApply performs a CheckApply for the file permissions. func (obj *FileRes) chmodCheckApply(ctx context.Context, apply bool) (bool, error) { - obj.init.Logf("chmodCheckApply(%t)", apply) + if obj.init.Debug { + obj.init.Logf("chmodCheckApply(%t)", apply) + } if obj.Mode == "" { // no mode specified, everything is ok