summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Stibane <marc@taler.net>2023-11-04 07:57:58 +0100
committerMarc Stibane <marc@taler.net>2023-11-04 07:59:05 +0100
commit370cbefa59dc6e18fa7022e2e671b3a9eb2ab8c5 (patch)
tree70dc2462794c0dedb0953915e0f21971ca07c412
parent3559d3680d5df0a1d76302c1b70436619473e457 (diff)
downloadtaler-ios-370cbefa59dc6e18fa7022e2e671b3a9eb2ab8c5.tar.gz
taler-ios-370cbefa59dc6e18fa7022e2e671b3a9eb2ab8c5.tar.bz2
taler-ios-370cbefa59dc6e18fa7022e2e671b3a9eb2ab8c5.zip
Logger
-rw-r--r--TalerWallet1/Backend/WalletCore.swift5
-rw-r--r--TalerWallet1/Controllers/TalerWallet1App.swift4
-rw-r--r--TalerWallet1/Views/Main/MainView.swift7
-rw-r--r--TalerWallet1/Views/Transactions/TransactionDetailView.swift9
4 files changed, 17 insertions, 8 deletions
diff --git a/TalerWallet1/Backend/WalletCore.swift b/TalerWallet1/Backend/WalletCore.swift
index 8fd3c18..e9e9ef1 100644
--- a/TalerWallet1/Backend/WalletCore.swift
+++ b/TalerWallet1/Backend/WalletCore.swift
@@ -190,14 +190,19 @@ extension WalletCore {
if let type = TransactionType(rawValue: components[1]) {
guard type != .refresh else { return }
if decoded.newTxState.major == .done {
+ logger.log("Done: \(decoded.transactionId, privacy: .private(mask: .hash))")
Controller.shared.playSound(type.isIncoming ? 2 : 1)
} else if decoded.newTxState.major == .expired {
+ logger.log("Expired: \(decoded.transactionId, privacy: .private(mask: .hash))")
Controller.shared.playSound(0)
}
postNotification(.TransactionStateTransition,
userInfo: [TRANSACTIONTRANSITION: decoded])
}
}
+ } else {
+ // TODO: Same state usually means that an error is transmitted
+ logger.log("No State change: \(decoded.transactionId, privacy: .private(mask: .hash))")
}
} catch { // rethrows
symLog.log(jsonData) // TODO: .error
diff --git a/TalerWallet1/Controllers/TalerWallet1App.swift b/TalerWallet1/Controllers/TalerWallet1App.swift
index 7f7fa50..9efb5be 100644
--- a/TalerWallet1/Controllers/TalerWallet1App.swift
+++ b/TalerWallet1/Controllers/TalerWallet1App.swift
@@ -10,8 +10,8 @@
*/
import BackgroundTasks
import SwiftUI
-import SymLog
import os.log
+import SymLog
@main
struct TalerWallet1App: App {
@@ -37,7 +37,7 @@ struct TalerWallet1App: App {
var body: some Scene {
WindowGroup {
- MainView(stack: CallStack("App"), soundPlayed: $soundPlayed)
+ MainView(logger: logger, stack: CallStack("App"), soundPlayed: $soundPlayed)
.environmentObject(debugViewC) // change viewID / sheetID
.environmentObject(viewState) // popToRoot
.environmentObject(controller)
diff --git a/TalerWallet1/Views/Main/MainView.swift b/TalerWallet1/Views/Main/MainView.swift
index 4a5e73b..56b166e 100644
--- a/TalerWallet1/Views/Main/MainView.swift
+++ b/TalerWallet1/Views/Main/MainView.swift
@@ -3,6 +3,7 @@
* See LICENSE.md
*/
import SwiftUI
+import os.log
import SymLog
// Use this to delay instantiation when using `NavigationLink`, etc...
@@ -15,6 +16,7 @@ struct LazyView<Content: View>: View {
struct MainView: View {
private let symLog = SymLogV(0)
+ let logger: Logger
let stack: CallStack
@EnvironmentObject private var viewState: ViewState // popToRootView()
@EnvironmentObject private var controller: Controller
@@ -33,7 +35,7 @@ struct MainView: View {
#endif
Group {
if controller.backendState == .ready {
- Content(symLog: symLog, stack: stack.push("Content"), talerFont: $talerFont)
+ Content(symLog: symLog, logger: logger, stack: stack.push("Content"), talerFont: $talerFont)
// any change to rootViewId triggers popToRootView behaviour
.id(viewState.rootViewId)
.onAppear() {
@@ -74,6 +76,7 @@ enum Tab {
extension MainView {
struct Content: View {
let symLog: SymLogV?
+ let logger: Logger
let stack: CallStack
@State private var shouldReloadBalances = 0
@State private var balances: [Balance] = []
@@ -220,7 +223,7 @@ extension MainView {
}
.onNotification(.BalanceChange) { notification in
// reload balances on receiving BalanceChange notification ...
- symLog?.log(".onNotification(.BalanceChange) ==> reload")
+ logger.info(".onNotification(.BalanceChange) ==> reload")
shouldReloadBalances += 1
}
.onChange(of: balances) { newArray in
diff --git a/TalerWallet1/Views/Transactions/TransactionDetailView.swift b/TalerWallet1/Views/Transactions/TransactionDetailView.swift
index 440818c..a4ad34f 100644
--- a/TalerWallet1/Views/Transactions/TransactionDetailView.swift
+++ b/TalerWallet1/Views/Transactions/TransactionDetailView.swift
@@ -121,20 +121,21 @@ struct TransactionDetailView: View {
}
}.onNotification(.TransactionStateTransition) { notification in
if let transition = notification.userInfo?[TRANSACTIONTRANSITION] as? TransactionTransition {
- if transition.transactionId == common.transactionId {
+ if transition.transactionId == common.transactionId { // is the transition for THIS transaction?
let newMajor = transition.newTxState.major
let newMinor = transition.newTxState.minor
if let doneAction {
if newMajor == .done {
symLog.log("newTxState.major == done => dismiss sheet")
+// TODO: logger.info("newTxState.major == done => dismiss sheet")
doneAction() // if this view is in a sheet this action will dissmiss it
} else if newMajor == .expired {
symLog.log("newTxState.major == expired => dismiss sheet")
+// TODO: logger.info("newTxState.major == expired => dismiss sheet")
doneAction() // if this view is in a sheet this action will dissmiss it
} else if newMajor == .pending {
if let newMinor {
if newMinor == .exchangeWaitReserve { // user did confirm on bank website
-// symLog.log("newTxState.minor == exchangeWaitReserve => change Buttons")
symLog.log("newTxState.minor == exchangeWaitReserve => dismiss sheet")
doneAction() // if this view is in a sheet this action will dissmiss it
} else if newMinor == .withdrawCoins { // coin-withdrawal has started
@@ -158,8 +159,8 @@ struct TransactionDetailView: View {
symLog.log(error.localizedDescription)
}}}
}
- } else {
- // Yikes - should never happen
+ } else { // Yikes - should never happen
+// TODO: logger.warning("Can't get notification.userInfo as TransactionTransition")
symLog.log(notification.userInfo as Any)
}
}