From fab4912b4902119c635ad5eeb23ff642bdcdab88 Mon Sep 17 00:00:00 2001 From: texasich Date: Thu, 9 Apr 2026 21:11:37 -0500 Subject: [PATCH] refactor: migrate data_source_github_branch logging to tflog Replace the stdlib `log` package with `tflog` in data_source_github_branch.go, contributing to the broader migration tracked in #3070. Structured key-value fields (org, repo, branch) are attached to the log entry alongside the formatted message, consistent with the pattern established in the other migrated files. Co-Authored-By: Claude Sonnet 4.6 --- github/data_source_github_branch.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/github/data_source_github_branch.go b/github/data_source_github_branch.go index 5b32b1c3e5..46fc8f2b9b 100644 --- a/github/data_source_github_branch.go +++ b/github/data_source_github_branch.go @@ -3,10 +3,11 @@ package github import ( "context" "errors" - "log" + "fmt" "net/http" "github.com/google/go-github/v84/github" + "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -54,7 +55,11 @@ func dataSourceGithubBranchRead(ctx context.Context, d *schema.ResourceData, met var ghErr *github.ErrorResponse if errors.As(err, &ghErr) { if ghErr.Response.StatusCode == http.StatusNotFound { - log.Printf("[DEBUG] Missing GitHub branch %s/%s (%s)", orgName, repoName, branchRefName) + tflog.Debug(ctx, fmt.Sprintf("Missing GitHub branch %s/%s (%s)", orgName, repoName, branchRefName), map[string]any{ + "org": orgName, + "repo": repoName, + "branch": branchRefName, + }) d.SetId("") return nil }