From 4aeb371acecf26a8ac6a4e746e7c5daaf277f29d Mon Sep 17 00:00:00 2001 From: Benjamin Bennett Date: Thu, 30 Mar 2023 15:43:04 +0100 Subject: [PATCH] Add documentation to use legacy logging when function does not supply context (#145) * Adding reference to functions in SDK that do not supply context and have to use legacy logging (#144) * Rewording (#144) --- website/docs/plugin/log/writing.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/plugin/log/writing.mdx b/website/docs/plugin/log/writing.mdx index bea3874..b0f2e1f 100644 --- a/website/docs/plugin/log/writing.mdx +++ b/website/docs/plugin/log/writing.mdx @@ -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.