diff --git a/internal/unifi/client.go b/internal/unifi/client.go index 47b125a..4ad03b4 100644 --- a/internal/unifi/client.go +++ b/internal/unifi/client.go @@ -109,51 +109,22 @@ func (c *httpClient) login() error { } func (c *httpClient) doRequest(method, path string, body io.Reader) (*http.Response, error) { - log.Debug("Do request", zap.String("method", method), zap.String("path", path)) - - // Convert body to bytes for logging and reuse - var bodyBytes []byte - if body != nil { - bodyBytes, _ = io.ReadAll(body) - body = bytes.NewReader(bodyBytes) - log.Debug("Request body", zap.String("body", string(bodyBytes))) - } - req, err := http.NewRequest(method, path, body) if err != nil { return nil, err } - // Set the required headers - if body != nil { - req.Header.Set("Content-Length", fmt.Sprintf("%d", len(bodyBytes))) - } - // Dynamically set the Host header - parsedURL, err := url.Parse(path) - if err != nil { - return nil, err - } - req.Host = parsedURL.Host c.setHeaders(req) resp, err := c.Client.Do(req) if err != nil { - log.Error("Request failed", zap.Error(err)) return nil, err } - // Log response body - respBody, _ := io.ReadAll(resp.Body) - log.Debug("response body", zap.String("body", string(respBody))) - resp.Body = io.NopCloser(bytes.NewBuffer(respBody)) // Restore the response body for further use - if csrf := resp.Header.Get("X-CSRF-Token"); csrf != "" { c.csrf = csrf - log.Debug("Updated CSRF token", zap.String("token", c.csrf)) } - log.Debug("recieved response", zap.String("method", method), zap.String("path", path), zap.Int("statusCode", resp.StatusCode)) - // If the status code is 401, re-login and retry the request if resp.StatusCode == http.StatusUnauthorized { log.Debug("received 401 unauthorized, attempting to re-login") @@ -183,8 +154,6 @@ func (c *httpClient) doRequest(method, path string, body io.Reader) (*http.Respo // GetEndpoints retrieves the list of DNS records from the UniFi controller. func (c *httpClient) GetEndpoints() ([]DNSRecord, error) { - log.Debug("Getting endpoints") - resp, err := c.doRequest( http.MethodGet, FormatUrl(c.ClientURLs.Records, c.Config.Host, c.Config.Site), diff --git a/pkg/webhook/webhook.go b/pkg/webhook/webhook.go index 564c60a..d61a04c 100644 --- a/pkg/webhook/webhook.go +++ b/pkg/webhook/webhook.go @@ -97,7 +97,6 @@ func (p *Webhook) Records(w http.ResponseWriter, r *http.Request) { return } - requestLog(r).Debug("requesting records") ctx := r.Context() records, err := p.provider.Records(ctx) if err != nil { @@ -106,7 +105,6 @@ func (p *Webhook) Records(w http.ResponseWriter, r *http.Request) { return } - requestLog(r).With(zap.Int("count", len(records))).Debug("returning records") w.Header().Set(contentTypeHeader, string(mediaTypeVersion1)) w.Header().Set(varyHeader, contentTypeHeader) err = json.NewEncoder(w).Encode(records)