Update with log/slog logging
Change-Id: Ie86d7082bb50576fdfbd898c44bd2905e389c399
diff --git a/server/git/github.go b/server/git/github.go
index 63424f1..6555b69 100644
--- a/server/git/github.go
+++ b/server/git/github.go
@@ -5,6 +5,7 @@
"context"
"encoding/json"
"fmt"
+ "log/slog"
"net/http"
"time"
)
@@ -14,6 +15,7 @@
Token string
BaseURL string // Default: https://api.github.com
HTTPClient *http.Client
+ Logger *slog.Logger
}
// GitHubPullRequestProvider implements PullRequestProvider for GitHub
@@ -21,6 +23,7 @@
config GitHubConfig
owner string
repo string
+ logger *slog.Logger
}
// NewGitHubPullRequestProvider creates a new GitHub pull request provider
@@ -31,11 +34,15 @@
if config.HTTPClient == nil {
config.HTTPClient = &http.Client{Timeout: 30 * time.Second}
}
+ if config.Logger == nil {
+ config.Logger = slog.Default()
+ }
return &GitHubPullRequestProvider{
config: config,
owner: owner,
repo: repo,
+ logger: config.Logger,
}
}
@@ -123,11 +130,15 @@
return nil, fmt.Errorf("failed to marshal request body: %w", err)
}
- // Debug logging for request data
- fmt.Printf("DEBUG: Creating PR with data: %s\n", string(jsonBody))
+ // Log PR creation with structured data
+ g.logger.Info("Creating GitHub PR",
+ slog.String("url", fmt.Sprintf("%s/repos/%s/%s/pulls", g.config.BaseURL, g.owner, g.repo)),
+ slog.String("title", options.Title),
+ slog.String("head_branch", options.HeadBranch),
+ slog.String("base_branch", options.BaseBranch),
+ slog.Any("labels", options.Labels))
url := fmt.Sprintf("%s/repos/%s/%s/pulls", g.config.BaseURL, g.owner, g.repo)
- fmt.Printf("DEBUG: POST URL: %s\n", url)
req, err := http.NewRequestWithContext(ctx, "POST", url, bytes.NewBuffer(jsonBody))
if err != nil {