summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Stibane <marc@taler.net>2024-04-05 23:12:16 +0200
committerMarc Stibane <marc@taler.net>2024-04-05 23:12:16 +0200
commit63cd1609f24380f36558d50bb73881bec1fc222b (patch)
treed3b676430f1970d40a760c8829bfa8c1862ba6ae
parent0e970ad5425ee6c77af2b231ae5b88a022292d98 (diff)
downloadtaler-ios-63cd1609f24380f36558d50bb73881bec1fc222b.tar.gz
taler-ios-63cd1609f24380f36558d50bb73881bec1fc222b.tar.bz2
taler-ios-63cd1609f24380f36558d50bb73881bec1fc222b.zip
Add Observability to LocalConsole
-rw-r--r--TalerWallet1/Backend/WalletCore.swift12
-rw-r--r--TalerWallet1/Views/Settings/SettingsView.swift20
2 files changed, 27 insertions, 5 deletions
diff --git a/TalerWallet1/Backend/WalletCore.swift b/TalerWallet1/Backend/WalletCore.swift
index ba00ead..8952261 100644
--- a/TalerWallet1/Backend/WalletCore.swift
+++ b/TalerWallet1/Backend/WalletCore.swift
@@ -31,6 +31,8 @@ class WalletCore: QuickjsMessageHandler {
var versionInfo: VersionInfo? // shown in SettingsView
var developDelay: Bool? // if set in SettingsView will delay wallet-core after each action
+ var isObserving: Bool
+ var isLogging: Bool
let logger = Logger(subsystem: "net.taler.gnu", category: "WalletCore")
private struct FullRequest: Encodable {
@@ -77,6 +79,8 @@ class WalletCore: QuickjsMessageHandler {
}
init() throws {
+ isObserving = false
+ isLogging = false
logger.info("init Quickjs")
requestsMade = 0
queue = DispatchQueue(label: "net.taler.myQueue", attributes: .concurrent)
@@ -307,7 +311,13 @@ print("\n❗️ WalletCore.swift:251 Notification: ", anyPayload, "\n") /
@MainActor func handleLog(message: String) {
let consoleManager = LCManager.shared
- if consoleManager.isVisible {
+ if isLogging {
+ consoleManager.print(message)
+ }
+ }
+ @MainActor func observe(message: String) {
+ let consoleManager = LCManager.shared
+ if isObserving {
consoleManager.print(message)
}
}
diff --git a/TalerWallet1/Views/Settings/SettingsView.swift b/TalerWallet1/Views/Settings/SettingsView.swift
index 8174f82..37ec955 100644
--- a/TalerWallet1/Views/Settings/SettingsView.swift
+++ b/TalerWallet1/Views/Settings/SettingsView.swift
@@ -39,7 +39,8 @@ struct SettingsView: View {
@AppStorage("developDelay") var developDelay: Bool = false
@AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic
@AppStorage("minimalistic") var minimalistic: Bool = false
- @AppStorage("localConsole") var localConsole: Bool = false
+ @AppStorage("localConsoleL") var localConsoleL: Bool = false // for Logs
+ @AppStorage("localConsoleO") var localConsoleO: Bool = false // for Observability
@State private var checkDisabled = false
@State private var withDrawDisabled = false
@@ -145,11 +146,22 @@ struct SettingsView: View {
// .id("font")
SettingsStyle(title: String(localized: "Liststyle:"), myListStyle: $myListStyle)
.id("liststyle")
+ let localConsStr = String(localized: "on LocalConsole")
+ let observability = String(localized: "Observability")
+ SettingsToggle(name: observability, value: $localConsoleO.onChange({ isObserving in
+ walletCore.isObserving = isObserving}), id1: "localConsoleO",
+ description: hideDescriptions ? nil : localConsStr) {
+ let consoleManager = LCManager.shared
+ consoleManager.isVisible = localConsoleO || localConsoleL
+ consoleManager.clear()
+ }
if diagnosticModeEnabled {
- SettingsToggle(name: String(localized: "LocalConsole"), value: $localConsole, id1: "localConsole",
- description: hideDescriptions ? nil : String(localized: "Show logs")) {
+ let showLogs = String(localized: "Show logs")
+ SettingsToggle(name: showLogs, value: $localConsoleL.onChange({ isLogging in
+ walletCore.isLogging = isLogging}), id1: "localConsoleL",
+ description: hideDescriptions ? nil : localConsStr) {
let consoleManager = LCManager.shared
- consoleManager.isVisible = localConsole
+ consoleManager.isVisible = localConsoleO || localConsoleL
consoleManager.clear()
}
SettingsToggle(name: String("Developer Mode"), value: $developerMode, id1: "devMode",