From f603030d64b66697589d4dfd7459212bd3353229 Mon Sep 17 00:00:00 2001 From: Uri Sternik Date: Wed, 13 Aug 2025 15:31:42 +0300 Subject: [PATCH 1/2] Fix JSON format ignored in some logging subsystems --- internal/logging/logging.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/internal/logging/logging.go b/internal/logging/logging.go index 5a479c01a935..0c99b7706f60 100644 --- a/internal/logging/logging.go +++ b/internal/logging/logging.go @@ -204,12 +204,26 @@ func globalLogLevel() (hclog.Level, bool) { if envLevel == "" { envLevel = strings.ToUpper(os.Getenv(envLogCore)) } - if envLevel == "JSON" { - json = true - } + + // Check if JSON formatting is requested by any subsystem + json = isJSONFormatRequested() + return parseLogLevel(envLevel), json } +// isJSONFormatRequested checks if any logging subsystem has requested JSON formatting +func isJSONFormatRequested() bool { + logEnvVars := []string{envLog, envLogCore, envLogProvider, envLogCloud, envLogStacks} + + for _, envVar := range logEnvVars { + if strings.ToUpper(os.Getenv(envVar)) == "JSON" { + return true + } + } + + return false +} + func parseLogLevel(envLevel string) hclog.Level { if envLevel == "" { return hclog.Off From 96644bb4e505f3391859df361c4903a630da7fd5 Mon Sep 17 00:00:00 2001 From: Uri Sternik Date: Thu, 14 Aug 2025 10:02:01 +0300 Subject: [PATCH 2/2] Add changelog entry --- .changes/v1.14/BUG FIXES-20250814-120000.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changes/v1.14/BUG FIXES-20250814-120000.yaml diff --git a/.changes/v1.14/BUG FIXES-20250814-120000.yaml b/.changes/v1.14/BUG FIXES-20250814-120000.yaml new file mode 100644 index 000000000000..e79dee1b4b50 --- /dev/null +++ b/.changes/v1.14/BUG FIXES-20250814-120000.yaml @@ -0,0 +1,5 @@ +kind: BUG FIXES +body: 'logging: Fixed JSON format being ignored in some logging subsystems when TF_LOG_* environment variables are set to "JSON"' +time: 2025-08-14T12:00:00.000000+00:00 +custom: + Issue: "37433"