diff --git a/configstack/module.go b/configstack/module.go index 4ecccf0ae0..e63efa1dcc 100644 --- a/configstack/module.go +++ b/configstack/module.go @@ -256,7 +256,7 @@ func FindWhereWorkingDirIsIncluded(ctx context.Context, opts *options.Terragrunt cfgOptions.OriginalTerragruntConfigPath = opts.OriginalTerragruntConfigPath cfgOptions.TerraformCommand = opts.TerraformCommand cfgOptions.NonInteractive = true - cfgOptions.Logger = opts.Logger.WithOptions(log.WithHooks(NewForceLogLevelHook(log.DebugLevel))) + cfgOptions.Logger = cfgOptions.Logger.WithOptions(log.WithHooks(NewForceLogLevelHook(log.DebugLevel))) // build stack from config directory stack, err := FindStackInSubfolders(ctx, cfgOptions, WithChildTerragruntConfig(terragruntConfig)) diff --git a/test/fixtures/log/levels/main.tf b/test/fixtures/log/levels/main.tf new file mode 100644 index 0000000000..0faafbc6c8 --- /dev/null +++ b/test/fixtures/log/levels/main.tf @@ -0,0 +1,3 @@ +output "text" { + value = "output" +} diff --git a/test/fixtures/log/levels/terragrunt.hcl b/test/fixtures/log/levels/terragrunt.hcl new file mode 100644 index 0000000000..bb7b160deb --- /dev/null +++ b/test/fixtures/log/levels/terragrunt.hcl @@ -0,0 +1 @@ +# Intentionally empty diff --git a/test/integration_test.go b/test/integration_test.go index df3bfa00b1..fc023e471c 100644 --- a/test/integration_test.go +++ b/test/integration_test.go @@ -69,6 +69,7 @@ const ( testFixtureInputs = "fixtures/inputs" testFixtureInputsFromDependency = "fixtures/inputs-from-dependency" testFixtureLogFormatter = "fixtures/log/formatter" + testFixtureLogStdoutLevel = "fixtures/log/levels" testFixtureLogRelPaths = "fixtures/log/rel-paths" testFixtureMissingDependence = "fixtures/missing-dependencies/main" testFixtureModulePathError = "fixtures/module-path-in-error" @@ -360,6 +361,26 @@ func TestLogFormatPrettyOutput(t *testing.T) { assert.Contains(t, stderr, "DEBUG Terragrunt Version:") } +func TestLogStdoutLevel(t *testing.T) { + t.Parallel() + + helpers.CleanupTerraformFolder(t, testFixtureLogStdoutLevel) + tmpEnvPath := helpers.CopyEnvironment(t, testFixtureLogStdoutLevel) + rootPath := util.JoinPath(tmpEnvPath, testFixtureLogStdoutLevel) + + stdout, stderr, err := helpers.RunTerragruntCommandWithOutput(t, "terragrunt apply -auto-approve --terragrunt-log-level trace --terragrunt-non-interactive -no-color --terragrunt-no-color --terragrunt-log-format=pretty --terragrunt-working-dir "+rootPath) + require.NoError(t, err) + + assert.Empty(t, stdout) + assert.Contains(t, stderr, "STDOUT "+wrappedBinary()+": Changes to Outputs") + + stdout, stderr, err = helpers.RunTerragruntCommandWithOutput(t, "terragrunt destroy -auto-approve --terragrunt-log-level trace --terragrunt-non-interactive -no-color --terragrunt-no-color --terragrunt-log-format=pretty --terragrunt-working-dir "+rootPath) + require.NoError(t, err) + + assert.Empty(t, stdout) + assert.Contains(t, stderr, "STDOUT "+wrappedBinary()+": Changes to Outputs") +} + func TestLogFormatKeyValueOutput(t *testing.T) { t.Parallel()