diff --git a/githubapp/middleware_logging.go b/githubapp/middleware_logging.go index 79a9c163..46b40e58 100644 --- a/githubapp/middleware_logging.go +++ b/githubapp/middleware_logging.go @@ -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) } @@ -113,6 +113,7 @@ type clientLoggingOptions struct { // Output control LogRateLimitInformation *RateLimitLoggingOption + LogGitHubRequestID bool } // RateLimitLoggingOption controls which rate limit information is logged. @@ -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: