diff options
-rw-r--r-- | TalerWallet.xcodeproj/project.pbxproj | 25 | ||||
-rw-r--r-- | TalerWallet1/Backend/WalletCore.swift | 8 | ||||
-rw-r--r-- | TalerWallet1/Quickjs/quickjs.swift | 8 | ||||
-rw-r--r-- | TalerWallet1/Views/Settings/SettingsView.swift | 8 |
4 files changed, 49 insertions, 0 deletions
diff --git a/TalerWallet.xcodeproj/project.pbxproj b/TalerWallet.xcodeproj/project.pbxproj index 7b870b8..7b0aa13 100644 --- a/TalerWallet.xcodeproj/project.pbxproj +++ b/TalerWallet.xcodeproj/project.pbxproj @@ -139,6 +139,7 @@ 4E578E942A4822D500F21F1C /* P2pPayURIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E578E932A4822D500F21F1C /* P2pPayURIView.swift */; }; 4E5A88F52A38A4FD00072618 /* QRCodeDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E5A88F42A38A4FD00072618 /* QRCodeDetailView.swift */; }; 4E5A88F72A3B9E5B00072618 /* WithdrawAcceptDone.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E5A88F62A3B9E5B00072618 /* WithdrawAcceptDone.swift */; }; + 4E5FA9A22B862C4A002DB016 /* LocalConsole in Frameworks */ = {isa = PBXBuildFile; productRef = 4E5FA9A12B862C4A002DB016 /* LocalConsole */; }; 4E605D902AA8B407002FB9A7 /* Nunito-Black.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 4E605D8E2AA8B407002FB9A7 /* Nunito-Black.ttf */; }; 4E605D912AA8B407002FB9A7 /* Nunito-Black.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 4E605D8E2AA8B407002FB9A7 /* Nunito-Black.ttf */; }; 4E605D922AA8B407002FB9A7 /* Nunito-BlackItalic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 4E605D8F2AA8B407002FB9A7 /* Nunito-BlackItalic.ttf */; }; @@ -175,6 +176,7 @@ 4E983C2A2ADBDD3500FA9CC5 /* SingleAxisGeometryReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E983C282ADBDD3500FA9CC5 /* SingleAxisGeometryReader.swift */; }; 4E983C2C2ADC416800FA9CC5 /* View+fitsSideBySide.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E983C2B2ADC416800FA9CC5 /* View+fitsSideBySide.swift */; }; 4E983C2D2ADC416800FA9CC5 /* View+fitsSideBySide.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E983C2B2ADC416800FA9CC5 /* View+fitsSideBySide.swift */; }; + 4EA076B12BBEED7E00685A10 /* LocalConsole in Frameworks */ = {isa = PBXBuildFile; productRef = 4EA076B02BBEED7E00685A10 /* LocalConsole */; }; 4EA1ABBE29A3833A008821EA /* PublicConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EA1ABBD29A3833A008821EA /* PublicConstants.swift */; }; 4EA551252A2C923600FEC9A8 /* CurrencyInputView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EA551242A2C923600FEC9A8 /* CurrencyInputView.swift */; }; 4EAD117629F672FA008EDD0B /* KeyboardResponder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EAD117529F672FA008EDD0B /* KeyboardResponder.swift */; }; @@ -462,6 +464,7 @@ files = ( 4E3EAE772A990778009F1BE8 /* AnyCodable in Frameworks */, 4E3EAE782A990778009F1BE8 /* SymLog in Frameworks */, + 4E5FA9A22B862C4A002DB016 /* LocalConsole in Frameworks */, 4E3EAE792A990778009F1BE8 /* FTalerWalletcore.framework in Frameworks */, 4EE171882B49635800BF9FF5 /* MarkdownUI in Frameworks */, 4E3EAE7A2A990778009F1BE8 /* taler-swift in Frameworks */, @@ -476,6 +479,7 @@ files = ( ABE97B1D286D82BF00580772 /* AnyCodable in Frameworks */, 4EB094FD29897D280043A8A1 /* SymLog in Frameworks */, + 4EA076B12BBEED7E00685A10 /* LocalConsole in Frameworks */, 4EB094F829897CA20043A8A1 /* FTalerWalletcore.framework in Frameworks */, 4E2D8DD32B3F513800234039 /* MarkdownUI in Frameworks */, ABC13AA32859962800D23185 /* taler-swift in Frameworks */, @@ -901,6 +905,7 @@ 4E3EAE1A2A990778009F1BE8 /* CodeScanner */, 4EE171872B49635800BF9FF5 /* MarkdownUI */, 4EE171912B49FE4E00BF9FF5 /* OrderedCollections */, + 4E5FA9A12B862C4A002DB016 /* LocalConsole */, ); productName = Taler; productReference = 4E3EAE892A990778009F1BE8 /* GNU_Taler.app */; @@ -927,6 +932,7 @@ 4EEC157529F8ECBF00D46A03 /* CodeScanner */, 4E2D8DD22B3F513800234039 /* MarkdownUI */, 4EE1718F2B49FE2B00BF9FF5 /* OrderedCollections */, + 4EA076B02BBEED7E00685A10 /* LocalConsole */, ); productName = Taler; productReference = D14AFD1D24D232B300C51073 /* Taler_Wallet.app */; @@ -1009,6 +1015,7 @@ 4EEC157429F8ECBF00D46A03 /* XCRemoteSwiftPackageReference "CodeScanner" */, 4E2D8DD12B3F513800234039 /* XCRemoteSwiftPackageReference "swift-markdown-ui-standalone" */, 4EE1718C2B49EB7200BF9FF5 /* XCRemoteSwiftPackageReference "swift-collections" */, + 4E5FA9A02B862638002DB016 /* XCRemoteSwiftPackageReference "LocalConsole" */, ); productRefGroup = D14AFD1E24D232B300C51073 /* Products */; projectDirPath = ""; @@ -1813,6 +1820,14 @@ minimumVersion = 2.0.0; }; }; + 4E5FA9A02B862638002DB016 /* XCRemoteSwiftPackageReference "LocalConsole" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/duraidabdul/LocalConsole"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 1.12.1; + }; + }; 4EB094FB29897D280043A8A1 /* XCRemoteSwiftPackageReference "SymLog" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/Fesh-com/SymLog"; @@ -1872,6 +1887,16 @@ package = 4E3EAE1B2A990778009F1BE8 /* XCRemoteSwiftPackageReference "CodeScanner" */; productName = CodeScanner; }; + 4E5FA9A12B862C4A002DB016 /* LocalConsole */ = { + isa = XCSwiftPackageProductDependency; + package = 4E5FA9A02B862638002DB016 /* XCRemoteSwiftPackageReference "LocalConsole" */; + productName = LocalConsole; + }; + 4EA076B02BBEED7E00685A10 /* LocalConsole */ = { + isa = XCSwiftPackageProductDependency; + package = 4E5FA9A02B862638002DB016 /* XCRemoteSwiftPackageReference "LocalConsole" */; + productName = LocalConsole; + }; 4EB094FC29897D280043A8A1 /* SymLog */ = { isa = XCSwiftPackageProductDependency; package = 4EB094FB29897D280043A8A1 /* XCRemoteSwiftPackageReference "SymLog" */; diff --git a/TalerWallet1/Backend/WalletCore.swift b/TalerWallet1/Backend/WalletCore.swift index 6e50295..ba00ead 100644 --- a/TalerWallet1/Backend/WalletCore.swift +++ b/TalerWallet1/Backend/WalletCore.swift @@ -7,6 +7,7 @@ import AnyCodable import FTalerWalletcore import SymLog import os +import LocalConsole /// Delegate for the wallet backend. protocol WalletBackendDelegate { @@ -304,6 +305,13 @@ print("\n❗️ WalletCore.swift:251 Notification: ", anyPayload, "\n") / } } + @MainActor func handleLog(message: String) { + let consoleManager = LCManager.shared + if consoleManager.isVisible { + consoleManager.print(message) + } + } + /// here not only responses, but also notifications from wallet-core will be received @MainActor func handleMessage(message: String) { do { diff --git a/TalerWallet1/Quickjs/quickjs.swift b/TalerWallet1/Quickjs/quickjs.swift index dbe796d..19fe572 100644 --- a/TalerWallet1/Quickjs/quickjs.swift +++ b/TalerWallet1/Quickjs/quickjs.swift @@ -12,6 +12,7 @@ import FTalerWalletcore public protocol QuickjsMessageHandler: AnyObject { func handleMessage(message: String) + func handleLog(message: String) } // MARK: - func notification_callback(userdata: Optional<UnsafeMutableRawPointer>, @@ -43,6 +44,7 @@ func logging_callback(userdata: Optional<UnsafeMutableRawPointer>, logger.trace("\(swiftTag, privacy: .public) \(swiftMessage, privacy: .public)") default: break } + quickjs.internalOnLog(message: swiftMessage) } // MARK: - public class Quickjs { // acts as singleton, since only one instance ever exists @@ -114,6 +116,12 @@ public class Quickjs { // acts as singleton, since only one instance ever e } } + public func internalOnLog(message: String) { + if let handler = messageHandler { + handler.handleLog(message: message) + } + } + // public func notifyNative() { // __notifyNative(instance) // } diff --git a/TalerWallet1/Views/Settings/SettingsView.swift b/TalerWallet1/Views/Settings/SettingsView.swift index b77a3be..3fe9a50 100644 --- a/TalerWallet1/Views/Settings/SettingsView.swift +++ b/TalerWallet1/Views/Settings/SettingsView.swift @@ -5,6 +5,7 @@ import SwiftUI import taler_swift import SymLog +import LocalConsole /* * Backup @@ -37,6 +38,7 @@ 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 @State private var checkDisabled = false @State private var withDrawDisabled = false @@ -130,6 +132,12 @@ struct SettingsView: View { SettingsStyle(title: String(localized: "Liststyle:"), myListStyle: $myListStyle) .id("liststyle") if diagnosticModeEnabled { + SettingsToggle(name: String(localized: "LocalConsole"), value: $localConsole, id1: "localConsole", + description: hideDescriptions ? nil : String(localized: "Show logs")) { + let consoleManager = LCManager.shared + consoleManager.isVisible = localConsole + consoleManager.clear() + } SettingsToggle(name: String("Developer Mode"), value: $developerMode, id1: "devMode", description: hideDescriptions ? nil : String("More information intended for debugging")) { withAnimation(Animation.linear.delay(0.8)) { showDevelopItems = developerMode } |