taler-ios

iOS apps for GNU Taler (wallet)
Log | Files | Refs | README | LICENSE

commit 9c3327f3698ceced471fce211ba541ea244d2401
parent 82ef850e1705da71ff85ca90b362ae7abea1cf8d
Author: Marc Stibane <marc@taler.net>
Date:   Sat, 15 Mar 2025 14:51:42 +0100

cleanup debug

Diffstat:
MTalerWallet1/Backend/WalletCore.swift | 64+++++++++++++++++++++++++++++++++-------------------------------
MTalerWallet1/Controllers/Controller.swift | 4+---
MTalerWallet1/Views/Balances/OIMView.swift | 18+++++++++---------
MTalerWallet1/Views/HelperViews/CurrencyField.swift | 2+-
MTalerWallet1/Views/HelperViews/CurrencyInputView.swift | 2+-
MTalerWallet1/Views/ViewModifier/View+innerSize.swift | 6+++---
6 files changed, 48 insertions(+), 48 deletions(-)

diff --git a/TalerWallet1/Backend/WalletCore.swift b/TalerWallet1/Backend/WalletCore.swift @@ -288,18 +288,18 @@ extension WalletCore { } // 3 components return } catch DecodingError.dataCorrupted(let context) { - print(context) + logger.error("\(context.debugDescription)") } catch DecodingError.keyNotFound(let key, let context) { - print("Key '\(key)' not found:", context.debugDescription) - print("codingPath:", context.codingPath) + logger.error("Key '\(key.stringValue)' not found:\(context.debugDescription)") + logger.error("\(context.codingPath)") } catch DecodingError.valueNotFound(let value, let context) { - print("Value '\(value)' not found:", context.debugDescription) - print("codingPath:", context.codingPath) + logger.error("Value '\(value)' not found:\(context.debugDescription)") + logger.error("\(context.codingPath)") } catch DecodingError.typeMismatch(let type, let context) { - print("Type '\(type)' mismatch:", context.debugDescription) - print("codingPath:", context.codingPath) + logger.error("Type '\(type)' mismatch:\(context.debugDescription)") + logger.error("\(context.codingPath)") } catch let error { // rethrows - symLog.log(error) // TODO: .error + logger.error("\(error.localizedDescription)") } throw WalletBackendError.walletCoreError(nil) // TODO: error? } @@ -374,11 +374,11 @@ extension WalletCore { // "refresh-revealed", "refresh-unwarranted": // break default: -print("\n❗️ WalletCore.swift:368 NEW Notification: ", message, "\n") // this is a new notification I haven't seen before + logger.error("NEW Notification: \(message)") // this is a new notification I haven't seen before break } } catch let error { - symLog.log("Error \(error) parsing notification: \(message)") // TODO: .error + logger.error("Error \(error) parsing notification: \(message)") postNotification(.Error, userInfo: [NOTIFICATIONERROR: error]) // TODO: if DevMode then should log into file for user } @@ -444,16 +444,18 @@ print("\n❗️ WalletCore.swift:368 NEW Notification: ", message, "\n") throw WalletBackendError.deserializationError } } catch DecodingError.dataCorrupted(let context) { - print(context) + logger.error("\(context.debugDescription)") } catch DecodingError.keyNotFound(let key, let context) { - print("Key '\(key)' not found:", context.debugDescription) - print("codingPath:", context.codingPath) + logger.error("Key '\(key.stringValue)' not found:\(context.debugDescription)") + logger.error("\(context.codingPath)") } catch DecodingError.valueNotFound(let value, let context) { - print("Value '\(value)' not found:", context.debugDescription) - print("codingPath:", context.codingPath) + logger.error("Value '\(value)' not found:\(context.debugDescription)") + logger.error("\(context.codingPath)") } catch DecodingError.typeMismatch(let type, let context) { - print("Type '\(type)' mismatch:", context.debugDescription) - print("codingPath:", context.codingPath) + logger.error("Type '\(type)' mismatch:\(context.debugDescription)") + logger.error("\(context.codingPath)") + } catch let error { + logger.error("\(error.localizedDescription)") } catch { // TODO: ? delegate?.walletBackendReceivedUnknownMessage(self, message: message) } @@ -497,14 +499,14 @@ extension WalletCore { let reqData = WalletBackendRequest(operation: request.operation(), args: AnyEncodable(request.args())) return try await withCheckedThrowingContinuation { continuation in - encodeAndSend(reqData) { requestId, timeSent, result, error in + encodeAndSend(reqData) { [self] requestId, timeSent, result, error in let timeUsed = Date.now - timeSent let millisecs = timeUsed.milliseconds if let error { - self.logger.error("Request \"id\":\(requestId, privacy: .public) failed after \(millisecs, privacy: .public) ms") + logger.error("Request \"id\":\(requestId, privacy: .public) failed after \(millisecs, privacy: .public) ms") } else { if millisecs > 50 { - self.logger.info("Request \"id\":\(requestId, privacy: .public) took \(millisecs, privacy: .public) ms") + logger.info("Request \"id\":\(requestId, privacy: .public) took \(millisecs, privacy: .public) ms") } } var err: Error? = nil @@ -514,30 +516,30 @@ extension WalletCore { continuation.resume(returning: (decoded, requestId)) return } catch DecodingError.dataCorrupted(let context) { - print(context) + logger.error("\(context.debugDescription)") } catch DecodingError.keyNotFound(let key, let context) { - print("Key '\(key)' not found:", context.debugDescription) - print("codingPath:", context.codingPath) + logger.error("Key '\(key.stringValue)' not found:\(context.debugDescription)") + logger.error("\(context.codingPath)") } catch DecodingError.valueNotFound(let value, let context) { - print("Value '\(value)' not found:", context.debugDescription) - print("codingPath:", context.codingPath) + logger.error("Value '\(value)' not found:\(context.debugDescription)") + logger.error("\(context.codingPath)") } catch DecodingError.typeMismatch(let type, let context) { - print("Type '\(type)' mismatch:", context.debugDescription) - print("codingPath:", context.codingPath) + logger.error("Type '\(type)' mismatch:\(context.debugDescription)") + logger.error("\(context.codingPath)") } catch { // rethrows if let jsonString = String(data: json, encoding: .utf8) { - self.symLog.log(jsonString) // TODO: .error + symLog.log(jsonString) // TODO: .error } else { - self.symLog.log(json) // TODO: .error + symLog.log(json) // TODO: .error } err = error // this will be thrown in continuation.resume(throwing:), otherwise keep nil } } else if let error { // TODO: WALLET_CORE_REQUEST_CANCELLED - self.lastError = FullError(type: "error", operation: request.operation(), id: requestId, error: error) + lastError = FullError(type: "error", operation: request.operation(), id: requestId, error: error) err = WalletBackendError.walletCoreError(error) } else { // both result and error are nil - self.lastError = nil + lastError = nil } continuation.resume(throwing: err ?? TransactionDecodingError.invalidStringValue) } diff --git a/TalerWallet1/Controllers/Controller.swift b/TalerWallet1/Controllers/Controller.swift @@ -75,9 +75,7 @@ class Controller: ObservableObject { func startObserving() { let defaults = UserDefaults.standard - self.oimModeObservation = defaults.observe(\.oimModeEnabled, options: [.new, .old, .prior, .initial]) { [weak self](object, change) in -// print(object, change) - print(UserDefaults.standard.oimModeEnabled) + self.oimModeObservation = defaults.observe(\.oimModeEnabled, options: [.new, .old, .prior, .initial]) { [weak self](_, _) in self?.oimModeActive = UserDefaults.standard.oimModeEnabled } self.diagnosticModeObservation = defaults.observe(\.diagnosticModeEnabled, options: [.new, .old,.prior,.initial]) { [weak self](_, _) in diff --git a/TalerWallet1/Views/Balances/OIMView.swift b/TalerWallet1/Views/Balances/OIMView.swift @@ -93,7 +93,7 @@ struct OIMcoinStackV: View { var body: some View { let number = count - 1 - let _ = print("CoinStack: \(count) * \(value) \(currency.coinBase)") +// let _ = print("CoinStack: \(count) * \(value) \(currency.coinBase)") if let size = currency.coinSize(value) { let offset = size / 16 ZStack { @@ -278,10 +278,10 @@ struct ColumnView: View { var body: some View { VStack { if column.topCount > 1 { - let _ = print("Stack: \(column.topCount) * \(column.topVal) \(currency.noteBase)") +// let _ = print("Stack: \(column.topCount) * \(column.topVal) \(currency.noteBase)") OIMstackV(value: column.topVal, count: column.topCount, currency: currency) } else { - let _ = print("Single: \(column.topVal) and \(column.botVal) \(currency.noteBase)") +// let _ = print("Single: \(column.topVal) and \(column.botVal) \(currency.noteBase)") OIMsingleV(value: column.topVal, currency: currency) if column.botVal > 0 { OIMsingleV(value: column.botVal, currency: currency) @@ -310,7 +310,7 @@ struct OIMView: View { let amount = balance.available if !amount.isZero { let value = amount.value * 100 // TODO: currency specs instead of 100 - print("intValue: \(Int(value)) \(currency.noteBase)") +// print("intValue: \(Int(value)) \(currency.noteBase)") return Int(value) } } @@ -326,7 +326,7 @@ struct OIMView: View { func addTopVal(andBot: Int, to columns: inout Columns) { if topVal > 0 { columns.append(Column(topCount: 1, topVal: topVal, botVal: andBot)) - print("add \(topVal) and \(andBot) \(currency.noteBase)") +// print("add \(topVal) and \(andBot) \(currency.noteBase)") topVal = 0 } else if andBot > 0 { topVal = andBot @@ -346,7 +346,7 @@ struct OIMView: View { cnt -= 5 } notes.append(Column(topCount: cnt, topVal: value, botVal: 0)) - print("notes: \(count) * \(value) \(currency.noteBase)") +// print("notes: \(count) * \(value) \(currency.noteBase)") } else { addTopVal(andBot: value, to: &notes) } @@ -364,7 +364,7 @@ struct OIMView: View { addTopVal(andBot: 0, to: &intCoins) } // else fill bottom later with smaller coin intCoins.append(Column(topCount: count, topVal: value, botVal: 0)) - print("intCoins: \(count) * \(value) \(currency.coinBase)") +// print("intCoins: \(count) * \(value) \(currency.coinBase)") } else { addTopVal(andBot: value, to: &intCoins) } @@ -377,7 +377,7 @@ struct OIMView: View { addTopVal(andBot: 0, to: &fracCoins) } // else fill bottom later with smaller coin fracCoins.append(Column(topCount: count, topVal: value, botVal: 0)) - print("fracCoins: \(count) * \(value) \(currency.coinBase)") +// print("fracCoins: \(count) * \(value) \(currency.coinBase)") } else { addTopVal(andBot: value, to: &fracCoins) } @@ -433,7 +433,7 @@ struct OIMView: View { Spacer() OIMcurrencyScroller(currency: currency, amount: $amount) .onChange(of: amount) { newValue in - print("new Amount: \(newValue)") +// print("new Amount: \(newValue)") let result = currency.notesCoins(newValue) buildColumns(result, currency: currency) } diff --git a/TalerWallet1/Views/HelperViews/CurrencyField.swift b/TalerWallet1/Views/HelperViews/CurrencyField.swift @@ -119,7 +119,7 @@ struct CurrencyTextfieldRepresentable: UIViewRepresentable { func updateText(amount: Amount) { let plain = amount.plainString(currencyInfo) - print("Setting textfield to: \(plain)") +// print("Setting textfield to: \(plain)") textField.text = plain let endPosition = textField.endOfDocument textField.selectedTextRange = textField.textRange(from: endPosition, to: endPosition) diff --git a/TalerWallet1/Views/HelperViews/CurrencyInputView.swift b/TalerWallet1/Views/HelperViews/CurrencyInputView.swift @@ -211,7 +211,7 @@ struct CurrencyInputView: View { if hasBeenShown { // print("❗️Yikes: CurrencyInputView hasBeenShown") } else if !UIAccessibility.isVoiceOverRunning { - print("❗️CurrencyInputView❗️") +// print("❗️CurrencyInputView❗️") DispatchQueue.main.asyncAfter(deadline: .now() + 0.7) { hasBeenShown = true if !currencyField.becomeFirstResponder() { diff --git a/TalerWallet1/Views/ViewModifier/View+innerSize.swift b/TalerWallet1/Views/ViewModifier/View+innerSize.swift @@ -55,7 +55,7 @@ extension View { } } .onPreferenceChange(InnerHeightKey.self) { newValue in - print("❗️InnerHeight \(newValue)❗️") +// print("❗️InnerHeight \(newValue)❗️") height.wrappedValue = newValue } } @@ -68,7 +68,7 @@ extension View { } } .onPreferenceChange(InnerWidthKey.self) { newValue in - print("❗️InnerWidth \(newValue)❗️") +// print("❗️InnerWidth \(newValue)❗️") width.wrappedValue = newValue } } @@ -81,7 +81,7 @@ extension View { } } .onPreferenceChange(InnerSizeKey.self) { newValue in - print("❗️InnerSize \(newValue)❗️") +// print("❗️InnerSize \(newValue)❗️") size.wrappedValue = newValue } }