[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-ios] 02/11: Native Logging for wallet-core (QuickJS)
From: |
gnunet |
Subject: |
[taler-taler-ios] 02/11: Native Logging for wallet-core (QuickJS) |
Date: |
Tue, 24 Oct 2023 22:45:18 +0200 |
This is an automated email from the git hooks/post-receive script.
marc-stibane pushed a commit to branch master
in repository taler-ios.
commit b41fb7403428b9bbbd827234e567d8302f1a2a2b
Author: Marc Stibane <marc@taler.net>
AuthorDate: Mon Oct 23 23:14:47 2023 +0200
Native Logging for wallet-core (QuickJS)
---
TalerWallet1/Model/WalletModel.swift | 4 +++-
TalerWallet1/Quickjs/quickjs.swift | 31 ++++++++++++++++++++++++++++++-
2 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/TalerWallet1/Model/WalletModel.swift
b/TalerWallet1/Model/WalletModel.swift
index 1bc239f..070e41c 100644
--- a/TalerWallet1/Model/WalletModel.swift
+++ b/TalerWallet1/Model/WalletModel.swift
@@ -94,13 +94,15 @@ fileprivate struct InitRequest:
WalletBackendFormattedRequest {
func args() -> Args {
return Args(persistentStoragePath: persistentStoragePath,
// cryptoWorkerType: "sync",
- logLevel: "info") // trace, info, warn,
error, none
+ logLevel: "info", // trace, info, warn,
error, none
+ useNativeLogging: true)
}
struct Args: Encodable {
var persistentStoragePath: String
// var cryptoWorkerType: String
var logLevel: String
+ var useNativeLogging: Bool
}
var persistentStoragePath: String
diff --git a/TalerWallet1/Quickjs/quickjs.swift
b/TalerWallet1/Quickjs/quickjs.swift
index b301190..54f42bd 100644
--- a/TalerWallet1/Quickjs/quickjs.swift
+++ b/TalerWallet1/Quickjs/quickjs.swift
@@ -3,13 +3,14 @@
* See LICENSE.md
*/
import Foundation
+import os.log
import FTalerWalletcore
public protocol QuickjsMessageHandler: AnyObject {
func handleMessage(message: String)
}
-
+// MARK: -
func notification_callback(userdata: Optional<UnsafeMutableRawPointer>,
payload: Optional<UnsafePointer<Int8>>) {
let native = Unmanaged<Quickjs>.fromOpaque(userdata!).takeUnretainedValue()
@@ -17,15 +18,43 @@ func notification_callback(userdata:
Optional<UnsafeMutableRawPointer>,
native.internalOnNotify(payload: string)
}
+func logging_callback(userdata: Optional<UnsafeMutableRawPointer>,
+ level: TALER_WALLET_LogLevel,
+ tag: Optional<UnsafePointer<Int8>>,
+ message: Optional<UnsafePointer<Int8>>) {
+ let native = Unmanaged<Quickjs>.fromOpaque(userdata!).takeUnretainedValue()
+ let theTag = String(cString: tag!)
+ let theMessage = String(cString: message!)
+
+ switch level {
+ case TALER_WALLET_LOG_ERROR:
+ native.logger.error("\(theTag, privacy: .public) \(theMessage,
privacy: .public)")
+ case TALER_WALLET_LOG_WARN:
+ native.logger.warning("\(theTag, privacy: .public) \(theMessage,
privacy: .public)")
+ case TALER_WALLET_LOG_MESSAGE:
+ native.logger.notice("\(theTag, privacy: .public) \(theMessage,
privacy: .public)")
+ case TALER_WALLET_LOG_INFO:
+ native.logger.info("\(theTag, privacy: .public) \(theMessage,
privacy: .public)")
+ case TALER_WALLET_LOG_TRACE:
+ native.logger.trace("\(theTag, privacy: .public) \(theMessage,
privacy: .public)")
+ default: break
+ }
+}
+// MARK: -
public class Quickjs {
var talerWalletInstance: OpaquePointer!
public weak var messageHandler: QuickjsMessageHandler?
+ var logger: Logger
public init() {
+ self.logger = Logger(subsystem: "net.taler.gnu", category: "QuickJS")
self.talerWalletInstance = TALER_WALLET_create()
TALER_WALLET_set_message_handler(talerWalletInstance,
notification_callback,
Unmanaged.passUnretained(self).toOpaque())
+ TALER_WALLET_set_log_handler(talerWalletInstance,
+ logging_callback,
+ Unmanaged.passUnretained(self).toOpaque())
TALER_WALLET_run(talerWalletInstance);
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-ios] branch master updated (a0c6bdb -> bf7f8e3), gnunet, 2023/10/24
- [taler-taler-ios] 01/11: Assets cleanup, gnunet, 2023/10/24
- [taler-taler-ios] 02/11: Native Logging for wallet-core (QuickJS),
gnunet <=
- [taler-taler-ios] 03/11: Logger, gnunet, 2023/10/24
- [taler-taler-ios] 05/11: Only call DetailsForAmount if non-zero, gnunet, 2023/10/24
- [taler-taler-ios] 10/11: CharacterSet+contains, gnunet, 2023/10/24
- [taler-taler-ios] 11/11: Layout for Pending - wip, gnunet, 2023/10/24
- [taler-taler-ios] 04/11: ExchangeRowView, gnunet, 2023/10/24
- [taler-taler-ios] 08/11: Cleanup, gnunet, 2023/10/24
- [taler-taler-ios] 09/11: DD51 - CurrencySpecification, gnunet, 2023/10/24
- [taler-taler-ios] 07/11: intValue, fracValue, valueAsTuple, gnunet, 2023/10/24
- [taler-taler-ios] 06/11: Fix for NavigationView popping back, gnunet, 2023/10/24