Skip to content

Update plugin logging to use tflog #419

Open
@jcardinal

Description

Terraform Version

terraform 1.5.7

Affected Resource(s)

Most or all

Repro Steps

  1. Create a situation that will cause a provider to log an event of WARN or ERROR level
  2. Run TF_LOG_PROVIDER=WARN TF_LOG_PATH=./tf.log terraform plan
  3. Review tf.log, notice the events are not shown

The issue is that we are using a deprecated logging pattern, and terraform encourages the use of their tflog package instead.

Expected Behavior

The log level specified by the provider should be understood correctly by terraform so filtering by log level works, and the user is not presenting with conflicting log levels.

Actual Behavior

We log all events as INFO level, while specifying our actual level as a string in the log message.

Steps to Reproduce

  1. Look at any logged event from the provider
  2. See the log level is INFO, regardless of what the provider specified using the log package, followed by the actual log level presented as a string at the beginning of the log message.

References

https://developer.hashicorp.com/terraform/plugin/log/writing

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions