Add trace logs to calls to external services

This commit is contained in:
Deluan 2023-01-31 09:37:09 -05:00
parent b6fcfa9fc8
commit 712d8f9fcc
4 changed files with 6 additions and 0 deletions

View File

@ -191,6 +191,7 @@ func (c *client) makeRequest(ctx context.Context, method string, params url.Valu
req, _ := http.NewRequestWithContext(ctx, method, apiBaseUrl, nil) req, _ := http.NewRequestWithContext(ctx, method, apiBaseUrl, nil)
req.URL.RawQuery = params.Encode() req.URL.RawQuery = params.Encode()
log.Trace(ctx, fmt.Sprintf("Sending Last.fm %s request", req.Method), "url", req.URL)
resp, err := c.hc.Do(req) resp, err := c.hc.Do(req)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -151,6 +151,7 @@ func (c *client) makeRequest(ctx context.Context, method string, endpoint string
req.Header.Add("Authorization", fmt.Sprintf("Token %s", r.ApiKey)) req.Header.Add("Authorization", fmt.Sprintf("Token %s", r.ApiKey))
} }
log.Trace(ctx, fmt.Sprintf("Sending ListenBrainz %s request", req.Method), "url", req.URL)
resp, err := c.hc.Do(req) resp, err := c.hc.Do(req)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -87,6 +87,7 @@ func (c *client) authorize(ctx context.Context) (string, error) {
} }
func (c *client) makeRequest(req *http.Request, response interface{}) error { func (c *client) makeRequest(req *http.Request, response interface{}) error {
log.Trace(req.Context(), fmt.Sprintf("Sending Spotify %s request", req.Method), "url", req.URL)
resp, err := c.hc.Do(req) resp, err := c.hc.Do(req)
if err != nil { if err != nil {
return err return err

View File

@ -37,6 +37,9 @@ var redacted = &Hook{
"([^\\w]s=)[^&]+", "([^\\w]s=)[^&]+",
"([^\\w]p=)[^&]+", "([^\\w]p=)[^&]+",
"([^\\w]jwt=)[^&]+", "([^\\w]jwt=)[^&]+",
// External services query params
"([^\\w]api_key=)[\\w]+",
}, },
} }