Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log redirector now respects TF_LOG #1772

Merged
merged 1 commit into from
Mar 21, 2024
Merged

Log redirector now respects TF_LOG #1772

merged 1 commit into from
Mar 21, 2024

Conversation

t0yv0
Copy link
Member

@t0yv0 t0yv0 commented Mar 20, 2024

Before this change all logs emitted with log.Printf were sent to Pulumi as DEBUG-level logs, making it difficult to detect errors and warnings emitted in this way, or to filter verbose logs to find errors or warnings.

Fixes #1632

The are two changes:

  • bridged providers will continue to send these logs as DEBUG-level logs by default but will now attach the original level label to the message, so that filtering verbose logs is easier

  • if the user sets the TF_LOG environment variable to an appropriate value such as TF_LOG=WARN, these logs will be sent to Pulumi at their correct level and will be made visible by Pulumi CLI

The TF_LOG-gated behavior matches Terraform behavior where seeing logs in the CLI is opt-in and disabled by default.

Copy link

codecov bot commented Mar 20, 2024

Codecov Report

Attention: Patch coverage is 64.91228% with 20 lines in your changes are missing coverage. Please review.

Project coverage is 59.47%. Comparing base (2d6a5c0) to head (0c08c5d).

Files Patch % Lines
pkg/tfbridge/log.go 66.07% 19 Missing ⚠️
pkg/tfbridge/provider.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1772      +/-   ##
==========================================
- Coverage   59.97%   59.47%   -0.50%     
==========================================
  Files         302      309       +7     
  Lines       42133    42540     +407     
==========================================
+ Hits        25268    25301      +33     
- Misses      15437    15813     +376     
+ Partials     1428     1426       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Before this change all logs emitted with `log.Printf` were sent to Pulumi as DEBUG-level logs, making it difficult to
detect errors and warnings emitted in this way, or to filter verbose logs to find errors or warnings.

The are two changes:

- bridged providers will continue to send these logs as DEBUG-level logs by default but will now attach the original
  level label to the message, so that filtering verbose logs is easier

- if the user sets the TF_LOG environment variable to an appropriate value such as TF_LOG=WARN, these logs will be sent
  to Pulumi at their correct level and will be made visible by Pulumi CLI

The TF_LOG-gated behavior matches Terraform behavior where seeing logs in the CLI is opt-in and disabled by default.
@t0yv0 t0yv0 merged commit d744c5d into master Mar 21, 2024
9 checks passed
@t0yv0 t0yv0 deleted the t0yv0/fix-1632 branch March 21, 2024 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot grep logs by level
2 participants