Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion githubapp/middleware_logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func ClientLogging(lvl zerolog.Level, opts ...ClientLoggingOption) ClientMiddlew
cached := res.Header.Get(httpcache.XFromCache) != ""
evt.Bool("cached", cached).
Int("status", res.StatusCode)
if requestID := res.Header.Get(httpHeaderRequestID); requestID != "" {
if requestID := res.Header.Get(httpHeaderRequestID); options.LogGitHubRequestID && requestID != "" {
evt.Str("github_request_id", requestID)
}

Expand Down Expand Up @@ -113,6 +113,7 @@ type clientLoggingOptions struct {

// Output control
LogRateLimitInformation *RateLimitLoggingOption
LogGitHubRequestID bool
}

// RateLimitLoggingOption controls which rate limit information is logged.
Expand Down Expand Up @@ -152,6 +153,13 @@ func LogRateLimitInformation(options *RateLimitLoggingOption) ClientLoggingOptio
}
}

// LogGitHubRequestID enables logging of the request ID returned by GitHub.
func LogGitHubRequestID() ClientLoggingOption {
return func(opts *clientLoggingOptions) {
opts.LogGitHubRequestID = true
}
}

func mirrorRequestBody(r *http.Request) (*http.Request, []byte, error) {
switch {
case r.Body == nil || r.Body == http.NoBody:
Expand Down