Skip to content
Open
Show file tree
Hide file tree
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: 6 additions & 4 deletions pkg/apiclient/auth_jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (t *JWTTransport) refreshJwtToken(ctx context.Context) error {
return fmt.Errorf("can't update scenario list: %w", err)
}

log.Debugf("scenarios list updated for '%s'", *t.MachineID)
log.Tracef("scenarios list updated for '%s'", *t.MachineID)
}

auth := models.WatcherAuthRequest{
Expand Down Expand Up @@ -117,7 +117,7 @@ func (t *JWTTransport) refreshJwtToken(ctx context.Context) error {
defer resp.Body.Close()

if resp.StatusCode < 200 || resp.StatusCode >= 300 {
log.Debugf("received response status %q when fetching %v", resp.Status, req.URL)
log.Tracef("received response status %q when fetching %v", resp.Status, req.URL)
Copy link
Member Author

@LaurenceJJones LaurenceJJones Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be useful at debug level 🤷🏻 but we already log the status anyways and URL so this could be removed?


err = CheckResponse(resp)
if err != nil {
Expand All @@ -144,7 +144,9 @@ func (t *JWTTransport) refreshJwtToken(ctx context.Context) error {
}
}

log.Debugf("token %s will expire on %s", t.Token, t.Expiration.String())
if log.IsLevelEnabled(log.TraceLevel) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrapped because t....String() causes allocation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what %v is for

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but %v doesnt log as human readable no?

log.Tracef("token %s will expire on %s", t.Token, t.Expiration.String())
}

select {
case t.TokenRefreshChan <- struct{}{}:
Expand Down Expand Up @@ -211,7 +213,7 @@ func (t *JWTTransport) RoundTrip(req *http.Request) (*http.Response, error) {
}

if resp != nil {
log.Debugf("resp-jwt: %d", resp.StatusCode)
log.Debugf("resp-jwt: http %d", resp.StatusCode)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to be consistent with resp-api: http 200 example

}

config, shouldRetry := t.RetryConfig.StatusCodeConfig[resp.StatusCode]
Expand Down
6 changes: 3 additions & 3 deletions pkg/apiclient/client_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ func (c *ApiClient) Do(ctx context.Context, req *http.Request, v any) (*Response
return newResponse(resp), err
}

if log.IsLevelEnabled(log.DebugLevel) {
if log.IsLevelEnabled(log.TraceLevel) {
for k, v := range resp.Header {
log.Debugf("[headers] %s: %s", k, v)
log.Tracef("[headers] %s: %s", k, v)
}

dump, err := httputil.DumpResponse(resp, true)
if err == nil {
log.Debugf("Response: %s", string(dump))
log.Tracef("Response: %s", string(dump))
}
}

Expand Down