Skip to content

Commit

Permalink
Add documentation to use legacy logging when function does not supply…
Browse files Browse the repository at this point in the history
… context (#145)

* Adding reference to functions in SDK that do not supply context and have to use legacy logging (#144)

* Rewording (#144)
  • Loading branch information
bendbennett committed Mar 30, 2023
1 parent 8294803 commit 4aeb371
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions website/docs/plugin/log/writing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ One of the following SDK versions is required to properly output structured logs
- [`terraform-plugin-framework`](/terraform/plugin/framework) version 0.6.0 or later
- [`terraform-plugin-sdk`](/terraform/plugin/sdkv2) version 2.10.0 or later

Follow the [legacy logging](#legacy-logging) instructions to write logs with older versions.

All calls to `tflog` package functionality must use an SDK provided `context.Context`, which stores the logging implementation. Every `terraform-plugin-framework` method implemented by providers automatically includes the correct `context.Context`. Providers written with `terraform-plugin-sdk` must use context-aware functionality, such as the [`helper/schema.Resource` type `ReadContext` field](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema#Resource.ReadContext).

Follow the [legacy logging](#legacy-logging) instructions to write logs with older SDK versions or when context-aware functionality is not available, for instance [SchemaStateFunc](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-sdk/helper/schema#SchemaStateFunc).

### Log Levels

You must choose a verbosity level for each line of log output. This lets consumers [specify a type of log output](/terraform/plugin/log/managing#log-levels) to write from your provider. For example, you can use environment fields to set your provider to write only logs of type `Warn` during a Terraform run.
Expand Down

0 comments on commit 4aeb371

Please sign in to comment.