From 043a7085156fd8b9e7cf21e2e7e3673c19872c3f Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Wed, 17 Apr 2024 17:04:32 -0400 Subject: [PATCH] Add more logging to onboarding VC --- .../Onboarding/OnboardingViewController.swift | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Tusker/Screens/Onboarding/OnboardingViewController.swift b/Tusker/Screens/Onboarding/OnboardingViewController.swift index 579e6cf5..36f2e775 100644 --- a/Tusker/Screens/Onboarding/OnboardingViewController.swift +++ b/Tusker/Screens/Onboarding/OnboardingViewController.swift @@ -116,10 +116,13 @@ class OnboardingViewController: UINavigationController { } private func tryLogin(to instanceURL: URL, updateStatus: (String) -> Void) async throws { + logger.debug("Attempting to log in to \(instanceURL, privacy: .public)") + let mastodonController = MastodonController(instanceURL: instanceURL, transient: true) let clientID: String let clientSecret: String if let clientInfo, clientInfo.url == instanceURL { + logger.debug("Using client info from previous attempt") clientID = clientInfo.id clientSecret = clientInfo.secret } else { @@ -127,21 +130,32 @@ class OnboardingViewController: UINavigationController { do { (clientID, clientSecret) = try await mastodonController.registerApp() self.clientInfo = (instanceURL, clientID, clientSecret) + logger.debug("Obtained client info") updateStatus("Reticulating Splines") try await Task.sleep(nanoseconds: 500 * NSEC_PER_MSEC) } catch { + logger.error("Failed to register app: \(String(describing: error), privacy: .public)") throw Error.registeringApp(error) } } updateStatus("Logging in") - let authCode = try await getAuthorizationCode(instanceURL: instanceURL, clientID: clientID) + let authCode: String + do { + authCode = try await getAuthorizationCode(instanceURL: instanceURL, clientID: clientID) + logger.debug("Obtained authorization code") + } catch { + logger.error("Failed to get auth code: \(String(describing: error), privacy: .public)") + throw error + } updateStatus("Authorizing") let accessToken: String do { accessToken = try await retrying("Getting access token") { try await mastodonController.authorize(authorizationCode: authCode) } + logger.debug("Obtained access token") } catch { + logger.error("Failed to get access token: \(String(describing: error), privacy: .public)") throw Error.gettingAccessToken(error) }