summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-03-29 15:45:24 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-03-29 15:45:24 +0200
commit85862b19ea13090d763f31054c3d8244c220704d (patch)
treee8cfc6e26f151094b51e11b4bb1e37e779ef7ea7
parenta6a6d0d42d70aff21cf759b3c2d7645c7475c5f3 (diff)
Logging: Add more logging statements
-rw-r--r--src/api.go1
-rw-r--r--src/oauth.go2
-rw-r--r--src/state.go4
3 files changed, 5 insertions, 2 deletions
diff --git a/src/api.go b/src/api.go
index 08e3819..76631b1 100644
--- a/src/api.go
+++ b/src/api.go
@@ -39,6 +39,7 @@ func (server *Server) apiAuthenticatedRetry(method string, endpoint string, opts
var error *HTTPStatusError
if errors.As(bodyErr, &error) {
+ GetVPNState().Log(LOG_INFO, fmt.Sprintf("API: Got HTTP error %v, retrying authenticated", bodyErr))
// Tell the method that the token is expired
server.OAuth.Token.ExpiredTimestamp = GenerateTimeSeconds()
return server.apiAuthenticated(method, endpoint, opts)
diff --git a/src/oauth.go b/src/oauth.go
index dd86279..45daf10 100644
--- a/src/oauth.go
+++ b/src/oauth.go
@@ -297,8 +297,10 @@ func (oauth *OAuth) Login() error {
func (oauth *OAuth) EnsureTokens() error {
if oauth.isTokensExpired() {
+ GetVPNState().Log(LOG_INFO, "OAuth: Tokens are expired, retrying with refresh tokens")
err := oauth.getTokensWithRefresh()
if err != nil {
+ GetVPNState().Log(LOG_INFO, fmt.Sprintf("OAuth: Refresh tokens with error %v, retrying with a new login phase", err))
// log that we're getting tokens using login
return oauth.Login()
}
diff --git a/src/state.go b/src/state.go
index 521390e..c146e61 100644
--- a/src/state.go
+++ b/src/state.go
@@ -24,14 +24,14 @@ func (state *VPNState) Register(name string, directory string, stateCallback fun
// Initialize the logger
state.InitLog(LOG_WARNING)
- state.Log(LOG_INFO, "App Registered")
+ state.Log(LOG_INFO, "App registered")
state.StateCallback("Start", "Registered", "app registered")
// Try to load the previous configuration
if state.LoadConfig() != nil {
// This error can be safely ignored, as when the config does not load, the struct will not be filled
- // Make sure to log this when we have implemented a good logging system
+ state.Log(LOG_INFO, "Previous configuration not found")
}
return nil
}