diff options
| author | Jeroen Wijenbergh <jeroen.wijenbergh@geant.org> | 2025-05-06 14:33:54 +0200 |
|---|---|---|
| committer | Jeroen Wijenbergh <jeroen.wijenbergh@geant.org> | 2025-05-06 15:40:55 +0200 |
| commit | 3f0c2643b4caadd3a47201caa2c6acba2585241d (patch) | |
| tree | cd6af32500156184d74d28c1476d18f33dbdee33 /internal/api | |
| parent | 15bef1fca407c21eed5d2c433051042c728468e6 (diff) | |
All: Move to log/slog
Diffstat (limited to 'internal/api')
| -rw-r--r-- | internal/api/api.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/internal/api/api.go b/internal/api/api.go index 4ee82b0..c34a0b0 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -6,6 +6,7 @@ import ( "encoding/json" "errors" "fmt" + "log/slog" "net/http" "net/url" "time" @@ -16,7 +17,6 @@ import ( "codeberg.org/eduVPN/eduvpn-common/internal/api/endpoints" "codeberg.org/eduVPN/eduvpn-common/internal/api/profiles" httpw "codeberg.org/eduVPN/eduvpn-common/internal/http" - "codeberg.org/eduVPN/eduvpn-common/internal/log" "codeberg.org/eduVPN/eduvpn-common/internal/wireguard" "codeberg.org/eduVPN/eduvpn-common/types/protocol" "codeberg.org/eduVPN/eduvpn-common/types/server" @@ -186,7 +186,7 @@ func (a *API) authorizedRetry(ctx context.Context, method string, endpoint strin // Only retry authorized if we get an HTTP 401 // TODO: Can the OAuth client handle this instead? if errors.As(err, &statErr) && statErr.Status == 401 { - log.Logger.Debugf("Got a 401 error after HTTP method: %s, endpoint: %s. Marking token as expired...", method, endpoint) + slog.Debug("Got a HTTP 401. Marking tokens as expired...", "HTTP method", method, "endpoint", endpoint) // Mark the token as expired and retry, so we trigger the refresh flow a.oauth.SetTokenExpired() h, body, err = a.authorized(ctx, method, endpoint, opts) @@ -196,7 +196,7 @@ func (a *API) authorizedRetry(ctx context.Context, method string, endpoint strin if err != nil && errors.As(err, &tErr) { // Mark the token as invalid and retry, so we trigger the authorization flow a.oauth.SetTokenRenew() - log.Logger.Debugf("the tokens were invalid, trying again...") + slog.Debug("The tokens were invalid, trying again...") if autherr := a.authorize(ctx); autherr != nil { return nil, nil, autherr } @@ -376,12 +376,12 @@ type OAuthLogger struct{} // Logf logs a message with parameters func (ol *OAuthLogger) Logf(msg string, params ...any) { - log.Logger.Debugf(msg, params...) + slog.Debug("OAuth log", "log", fmt.Sprintf(msg, params...)) } // Log logs a message func (ol *OAuthLogger) Log(msg string) { - log.Logger.Debugf("%s", msg) + slog.Debug("OAuth log", "log", msg) } func init() { |
