-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Raise the default log level of TF from WARN to ERROR
Fixes pulumi/pulumi-aws#3389
- Loading branch information
Showing
2 changed files
with
19 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,8 @@ import ( | |
func TestLogging(t *testing.T) { | ||
urn := resource.URN("urn:pulumi:prod::web::custom:resources:Resource$random:index/password:Password::my-pw") | ||
|
||
warn := map[string]string{"TF_LOG": "WARN"} | ||
|
||
cases := []struct { | ||
name string | ||
opts LogOptions | ||
|
@@ -39,8 +41,11 @@ func TestLogging(t *testing.T) { | |
env map[string]string | ||
}{ | ||
{ | ||
name: "WARN and higher propagates by default", | ||
name: "logging is disabled by default", | ||
opts: LogOptions{}, | ||
env: map[string]string{ | ||
"TF_LOG": "", | ||
}, | ||
emit: func(ctx context.Context) { | ||
tflog.Trace(ctx, "Something went wrong TRACE") | ||
tflog.Debug(ctx, "Something went wrong DEBUG") | ||
|
@@ -49,10 +54,6 @@ func TestLogging(t *testing.T) { | |
tflog.Error(ctx, "Something went wrong ERROR ") | ||
}, | ||
logs: []log{ | ||
{ | ||
msg: `Something went wrong WARN`, | ||
sev: diag.Warning, | ||
}, | ||
{ | ||
msg: `Something went wrong ERROR`, | ||
sev: diag.Error, | ||
|
@@ -114,13 +115,15 @@ func TestLogging(t *testing.T) { | |
{ | ||
name: "URN propagates when set", | ||
opts: LogOptions{URN: urn}, | ||
env: warn, | ||
emit: func(ctx context.Context) { | ||
tflog.Warn(ctx, "OK") | ||
}, | ||
logs: []log{{sev: diag.Warning, msg: `OK`, urn: urn}}, | ||
}, | ||
{ | ||
name: "Provider propagates when set", | ||
env: warn, | ||
opts: LogOptions{ProviderName: "random"}, | ||
emit: func(ctx context.Context) { | ||
tflog.Warn(ctx, "OK") | ||
|
@@ -130,13 +133,15 @@ func TestLogging(t *testing.T) { | |
{ | ||
name: "ProviderVersion propagates when set", | ||
opts: LogOptions{ProviderName: "random", ProviderVersion: "4.12.0"}, | ||
env: warn, | ||
emit: func(ctx context.Context) { | ||
tflog.Warn(ctx, "OK") | ||
}, | ||
logs: []log{{sev: diag.Warning, msg: `provider\[email protected]`}}, | ||
}, | ||
{ | ||
name: "User Logging", | ||
env: warn, | ||
opts: LogOptions{URN: urn}, | ||
emit: func(ctx context.Context) { | ||
log := getLogger(ctx) | ||
|