Skip to content

🎧 Your Personal Streaming Service

Add trace logs to calls to external services

Deluan712d8f9fcc99
diff --git a/core/agents/lastfm/client.go b/core/agents/lastfm/client.go
index d8b76d3c1..a993ddc51 100644
--- a/core/agents/lastfm/client.go
+++ b/core/agents/lastfm/client.go
@@ -191,6 +191,7 @@ func (c *client) makeRequest(ctx context.Context, method string, params url.Valu
req, _ := http.NewRequestWithContext(ctx, method, apiBaseUrl, nil)
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)
if err != nil {
return nil, err
diff --git a/core/agents/listenbrainz/client.go b/core/agents/listenbrainz/client.go
index 3e48462f6..8ed4d1691 100644
--- a/core/agents/listenbrainz/client.go
+++ b/core/agents/listenbrainz/client.go
@@ -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))
}
+ log.Trace(ctx, fmt.Sprintf("Sending ListenBrainz %s request", req.Method), "url", req.URL)
resp, err := c.hc.Do(req)
if err != nil {
return nil, err
diff --git a/core/agents/spotify/client.go b/core/agents/spotify/client.go
index 0ac310f69..25b1f9ede 100644
--- a/core/agents/spotify/client.go
+++ b/core/agents/spotify/client.go
@@ -87,6 +87,7 @@ func (c *client) authorize(ctx context.Context) (string, 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)
if err != nil {
return err
diff --git a/log/log.go b/log/log.go
index a0a9fd3c3..d20fa8e39 100644
--- a/log/log.go
+++ b/log/log.go
@@ -37,6 +37,9 @@ var redacted = &Hook{
"([^\\w]s=)[^&]+",
"([^\\w]p=)[^&]+",
"([^\\w]jwt=)[^&]+",
+
+ // External services query params
+ "([^\\w]api_key=)[\\w]+",
},
}