Skip to content

Commit 4f607e6

Browse files
authored
Nice debug logs (#463)
* Nice debug logs * fixup! Merge branch 'main' into nice-debug-logs
1 parent e139a85 commit 4f607e6

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
kind: NOTES
2+
body: reduced the volume of DEBUG-level logging to make it easier to visually scan debug output
3+
time: 2025-03-25T08:44:49.949718-04:00
4+
custom:
5+
Issue: "463"

helper/resource/plugin.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,14 @@ func runProviderCommand(ctx context.Context, t testing.T, f func() error, wd *pl
178178
providerName = strings.TrimPrefix(providerName, "terraform-provider-")
179179
providerAddress := getProviderAddr(providerName)
180180

181-
logging.HelperResourceDebug(ctx, "Creating sdkv2 provider instance", map[string]interface{}{logging.KeyProviderAddress: providerAddress})
181+
logging.HelperResourceTrace(ctx, "Creating sdkv2 provider instance", map[string]interface{}{logging.KeyProviderAddress: providerAddress})
182182

183183
provider, err := factory()
184184
if err != nil {
185185
return fmt.Errorf("unable to create provider %q from factory: %w", providerName, err)
186186
}
187187

188-
logging.HelperResourceDebug(ctx, "Created sdkv2 provider instance", map[string]interface{}{logging.KeyProviderAddress: providerAddress})
188+
logging.HelperResourceTrace(ctx, "Created sdkv2 provider instance", map[string]interface{}{logging.KeyProviderAddress: providerAddress})
189189

190190
// keep track of the running factory, so we can make sure it's
191191
// shut down.
@@ -215,14 +215,14 @@ func runProviderCommand(ctx context.Context, t testing.T, f func() error, wd *pl
215215
ProviderAddr: providerAddress,
216216
}
217217

218-
logging.HelperResourceDebug(ctx, "Starting sdkv2 provider instance server", map[string]interface{}{logging.KeyProviderAddress: providerAddress})
218+
logging.HelperResourceTrace(ctx, "Starting sdkv2 provider instance server", map[string]interface{}{logging.KeyProviderAddress: providerAddress})
219219

220220
config, closeCh, err := plugin.DebugServe(ctx, opts)
221221
if err != nil {
222222
return fmt.Errorf("unable to serve provider %q: %w", providerName, err)
223223
}
224224

225-
logging.HelperResourceDebug(ctx, "Started sdkv2 provider instance server", map[string]interface{}{logging.KeyProviderAddress: providerAddress})
225+
logging.HelperResourceTrace(ctx, "Started sdkv2 provider instance server", map[string]interface{}{logging.KeyProviderAddress: providerAddress})
226226

227227
tfexecConfig := tfexec.ReattachConfig{
228228
Protocol: config.Protocol,
@@ -272,14 +272,14 @@ func runProviderCommand(ctx context.Context, t testing.T, f func() error, wd *pl
272272
}
273273
}
274274

275-
logging.HelperResourceDebug(ctx, "Creating tfprotov5 provider instance", map[string]interface{}{logging.KeyProviderAddress: providerAddress})
275+
logging.HelperResourceTrace(ctx, "Creating tfprotov5 provider instance", map[string]interface{}{logging.KeyProviderAddress: providerAddress})
276276

277277
provider, err := factory()
278278
if err != nil {
279279
return fmt.Errorf("unable to create provider %q from factory: %w", providerName, err)
280280
}
281281

282-
logging.HelperResourceDebug(ctx, "Created tfprotov5 provider instance", map[string]interface{}{logging.KeyProviderAddress: providerAddress})
282+
logging.HelperResourceTrace(ctx, "Created tfprotov5 provider instance", map[string]interface{}{logging.KeyProviderAddress: providerAddress})
283283

284284
// keep track of the running factory, so we can make sure it's
285285
// shut down.
@@ -303,14 +303,14 @@ func runProviderCommand(ctx context.Context, t testing.T, f func() error, wd *pl
303303
ProviderAddr: providerAddress,
304304
}
305305

306-
logging.HelperResourceDebug(ctx, "Starting tfprotov5 provider instance server", map[string]interface{}{logging.KeyProviderAddress: providerAddress})
306+
logging.HelperResourceTrace(ctx, "Starting tfprotov5 provider instance server", map[string]interface{}{logging.KeyProviderAddress: providerAddress})
307307

308308
config, closeCh, err := plugin.DebugServe(ctx, opts)
309309
if err != nil {
310310
return fmt.Errorf("unable to serve provider %q: %w", providerName, err)
311311
}
312312

313-
logging.HelperResourceDebug(ctx, "Started tfprotov5 provider instance server", map[string]interface{}{logging.KeyProviderAddress: providerAddress})
313+
logging.HelperResourceTrace(ctx, "Started tfprotov5 provider instance server", map[string]interface{}{logging.KeyProviderAddress: providerAddress})
314314

315315
tfexecConfig := tfexec.ReattachConfig{
316316
Protocol: config.Protocol,
@@ -361,14 +361,14 @@ func runProviderCommand(ctx context.Context, t testing.T, f func() error, wd *pl
361361
}
362362
}
363363

364-
logging.HelperResourceDebug(ctx, "Creating tfprotov6 provider instance", map[string]interface{}{logging.KeyProviderAddress: providerAddress})
364+
logging.HelperResourceTrace(ctx, "Creating tfprotov6 provider instance", map[string]interface{}{logging.KeyProviderAddress: providerAddress})
365365

366366
provider, err := factory()
367367
if err != nil {
368368
return fmt.Errorf("unable to create provider %q from factory: %w", providerName, err)
369369
}
370370

371-
logging.HelperResourceDebug(ctx, "Created tfprotov6 provider instance", map[string]interface{}{logging.KeyProviderAddress: providerAddress})
371+
logging.HelperResourceTrace(ctx, "Created tfprotov6 provider instance", map[string]interface{}{logging.KeyProviderAddress: providerAddress})
372372

373373
// keep track of the running factory, so we can make sure it's
374374
// shut down.
@@ -388,14 +388,14 @@ func runProviderCommand(ctx context.Context, t testing.T, f func() error, wd *pl
388388
ProviderAddr: providerAddress,
389389
}
390390

391-
logging.HelperResourceDebug(ctx, "Starting tfprotov6 provider instance server", map[string]interface{}{logging.KeyProviderAddress: providerAddress})
391+
logging.HelperResourceTrace(ctx, "Starting tfprotov6 provider instance server", map[string]interface{}{logging.KeyProviderAddress: providerAddress})
392392

393393
config, closeCh, err := plugin.DebugServe(ctx, opts)
394394
if err != nil {
395395
return fmt.Errorf("unable to serve provider %q: %w", providerName, err)
396396
}
397397

398-
logging.HelperResourceDebug(ctx, "Started tfprotov6 provider instance server", map[string]interface{}{logging.KeyProviderAddress: providerAddress})
398+
logging.HelperResourceTrace(ctx, "Started tfprotov6 provider instance server", map[string]interface{}{logging.KeyProviderAddress: providerAddress})
399399

400400
tfexecConfig := tfexec.ReattachConfig{
401401
Protocol: config.Protocol,
@@ -441,7 +441,7 @@ func runProviderCommand(ctx context.Context, t testing.T, f func() error, wd *pl
441441
}
442442

443443
logging.HelperResourceTrace(ctx, "Called wrapped Terraform CLI command")
444-
logging.HelperResourceDebug(ctx, "Stopping providers")
444+
logging.HelperResourceTrace(ctx, "Stopping providers")
445445

446446
// cancel the servers so they'll return. Otherwise, this closeCh won't
447447
// get closed, and we'll hang here.

helper/resource/testing.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -929,11 +929,7 @@ func Test(t testing.T, c TestCase) {
929929
// This is done after creating the helper because a working directory is required
930930
// to retrieve the Terraform version.
931931
if c.TerraformVersionChecks != nil {
932-
logging.HelperResourceDebug(ctx, "Calling TestCase Terraform version checks")
933-
934932
runTFVersionChecks(ctx, t, helper.TerraformVersion(), c.TerraformVersionChecks)
935-
936-
logging.HelperResourceDebug(ctx, "Called TestCase Terraform version checks")
937933
}
938934

939935
runNewTest(ctx, t, c, helper)

helper/resource/testing_new.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,6 @@ func runNewTest(ctx context.Context, t testing.T, c TestCase, helper *plugintest
129129
}
130130
}
131131

132-
logging.HelperResourceDebug(ctx, "Starting TestSteps")
133-
134132
// use this to track last step successfully applied
135133
// acts as default for import tests
136134
var appliedCfg string

0 commit comments

Comments
 (0)