terratest icon indicating copy to clipboard operation
terratest copied to clipboard

Question: how to suppress log from retry.go:91

Open aad opened this issue 3 years ago • 2 comments

Hi Team, all

Even logger is set to Discard (Logger: logger.Discard) in terraformOptions, we still see below output in console when go test. Any suggestions how to suppress them?

TestStandardCase 2021-09-14T15:46:34+08:00 retry.go:91: terraform [output -no-color -json]
TestFifoCase 2021-09-14T15:46:34+08:00 retry.go:91: terraform [output -no-color -json]
TestStandardCase 2021-09-14T15:46:35+08:00 retry.go:91: terraform [workspace list]
TestFifoCase 2021-09-14T15:46:35+08:00 retry.go:91: terraform [workspace list]
TestStandardCase 2021-09-14T15:46:36+08:00 retry.go:91: terraform [workspace select default]
TestFifoCase 2021-09-14T15:46:36+08:00 retry.go:91: terraform [workspace select default]
TestStandardCase 2021-09-14T15:46:37+08:00 retry.go:91: terraform [workspace show]
TestFifoCase 2021-09-14T15:46:37+08:00 retry.go:91: terraform [workspace show]
TestStandardCase 2021-09-14T15:46:38+08:00 retry.go:91: terraform [init -upgrade=false]
TestFifoCase 2021-09-14T15:46:38+08:00 retry.go:91: terraform [init -upgrade=false]
...
TestFifoCase 2021-09-14T15:49:55+08:00 sqs.go:206: Message id 144f75e2-c634-426c-9461-zzzzzzzz sent to queue https://sqs.x.amazonaws.com/y/demo-demo-oneinoneout.fifo

aad avatar Sep 14 '21 07:09 aad

We currently don't support a way to suppress them in a nice way, as these functions are logging from the Logf function directly in the logger package, and not using the newer Logger object.

A PR to update the retry functions to support passing through a Logger object would be appreciated!

yorinasub17 avatar Sep 24 '21 22:09 yorinasub17

Hi @yorinasub17

I would like to pick this up and implement these changes. My question though is what is the preferred behavior:

  1. Changing the last argument for all functions in the retry package from anonymous function to some new struct called Action where we could provide logger instance and fallback to logger.Default when missing (going further we could encapsulate by this action not only the function but also other arguments as well)
  2. Adding additional argument with the logger function
  3. Maybe just changing logging.Logf to logging.Default.Logf?
  4. Something else?

bartsmykla avatar Feb 15 '22 15:02 bartsmykla