summaryrefslogtreecommitdiff
path: root/internal/api
diff options
context:
space:
mode:
Diffstat (limited to 'internal/api')
-rw-r--r--internal/api/api.go10
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() {