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

Separate loggers #26685

Merged
merged 3 commits into from
Oct 23, 2020
Merged

Separate loggers #26685

merged 3 commits into from
Oct 23, 2020

Conversation

jbardin
Copy link
Member

@jbardin jbardin commented Oct 23, 2020

Both core and provider logs can be quite verbose, and it is often difficult to debug one or the other while sifting through the combination of their logs.

Here we introduce two new environment variables for more control over logging:

TF_LOG_CORE=level
TF_LOG_PROVIDER=level

The existing TF_LOG environment variable remains to set the global log level, but these new variables allow the viewing of the subsystem logs independently.

Added an Off level to hclog, so we can individually disable logging at
various levels.

Added IndependentLevels so that sublogger levels are not linked to their
parents.
@codecov
Copy link

codecov bot commented Oct 23, 2020

Codecov Report

Merging #26685 into master will decrease coverage by 0.00%.
The diff coverage is 30.55%.

Impacted Files Coverage Δ
command/meta_providers.go 35.55% <0.00%> (ø)
command/plugins.go 38.27% <0.00%> (ø)
internal/logging/panic.go 0.00% <0.00%> (ø)
main.go 37.74% <ø> (+0.18%) ⬆️
internal/logging/logging.go 31.14% <35.48%> (-5.03%) ⬇️
terraform/eval_apply.go 74.01% <0.00%> (-0.61%) ⬇️
terraform/evaluate.go 52.91% <0.00%> (+0.41%) ⬆️
dag/marshal.go 54.79% <0.00%> (+1.36%) ⬆️
internal/providercache/dir.go 71.42% <0.00%> (+6.12%) ⬆️

@jbardin jbardin force-pushed the jbardin/separate-loggers branch from 43e1ca6 to 22f753a Compare October 23, 2020 13:01
@jbardin jbardin requested a review from a team October 23, 2020 13:17
Now that hclog can independently set levels on related loggers, we can
separate the log levels for different subsystems in terraform.

This adds the new environment variables, `TF_LOG_CORE` and
`TF_LOG_PROVIDER`, which each take the same set of log level arguments,
and only applies to logs from that subsystem. This means that setting
`TF_LOG_CORE=level` will not show logs from providers, and
`TF_LOG_PROVIDER=level` will not show logs from core. The behavior of
`TF_LOG` alone does not change.

While it is not necessarily needed since the default is to disable logs,
there is also a new level argument of `off`, which reflects the
associated level in hclog.
@jbardin jbardin force-pushed the jbardin/separate-loggers branch from f598cbc to eb2d443 Compare October 23, 2020 16:46
@mildwonkey
Copy link
Contributor

This is SO AWESOME this PR needs some PR; everyone needs to see how cool it is.

@ghost
Copy link

ghost commented Nov 23, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked as resolved and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants