aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-02-02 20:46:16 +0100
committerFlorian Dold <florian@dold.me>2023-02-02 20:46:16 +0100
commita0ecc7ca8d72a192c1807b4099d5318e064ae79f (patch)
tree93d51cd2e5a3d3fff419884f472f3ca4b0727c99
parent9d6613619e052aba429e042a25744f1160950d15 (diff)
embedded: allow setting logLevel in init message
-rw-r--r--packages/taler-wallet-embedded/src/wallet-qjs.ts26
1 files changed, 18 insertions, 8 deletions
diff --git a/packages/taler-wallet-embedded/src/wallet-qjs.ts b/packages/taler-wallet-embedded/src/wallet-qjs.ts
index c4178e596..f7b73711c 100644
--- a/packages/taler-wallet-embedded/src/wallet-qjs.ts
+++ b/packages/taler-wallet-embedded/src/wallet-qjs.ts
@@ -37,6 +37,7 @@ import {
CoreApiMessageEnvelope,
CoreApiResponse,
CoreApiResponseSuccess,
+ InitRequest,
j2s,
Logger,
setGlobalLogLevelFromString,
@@ -265,6 +266,7 @@ export async function getWallet(args: DefaultNodeWalletArgs = {}): Promise<{
class NativeWalletMessageHandler {
walletArgs: DefaultNodeWalletArgs | undefined;
+ initRequest: InitRequest = {};
maybeWallet: Wallet | undefined;
wp = openPromise<Wallet>();
httpLib = new NativeHttpLib();
@@ -293,11 +295,9 @@ class NativeWalletMessageHandler {
const wR = await getWallet(this.walletArgs);
const w = wR.wallet;
this.maybeWallet = w;
- const resp = await w.handleCoreApiRequest(
- "initWallet",
- "native-init",
- {...this.walletArgs},
- );
+ const resp = await w.handleCoreApiRequest("initWallet", "native-init", {
+ ...this.initRequest,
+ });
initResponse = resp.type == "response" ? resp.result : resp.error;
w.runTaskLoop().catch((e) => {
logger.error(
@@ -309,8 +309,10 @@ class NativeWalletMessageHandler {
switch (operation) {
case "init": {
- this.walletArgs = {
+ this.initRequest = {
...args,
+ };
+ this.walletArgs = {
notifyHandler: async (notification: WalletNotification) => {
sendNativeMessage({ type: "notification", payload: notification });
},
@@ -318,6 +320,10 @@ class NativeWalletMessageHandler {
httpLib: this.httpLib,
cryptoWorkerType: args.cryptoWorkerType,
};
+ const logLevel = args.logLevel;
+ if (logLevel) {
+ setGlobalLogLevelFromString(logLevel);
+ }
await reinit();
return wrapResponse({
...initResponse,
@@ -383,7 +389,11 @@ export function installNativeWalletListener(): void {
logger.info(`native listener: got request for ${operation} (${id})`);
try {
- const respMsg = await handler.handleMessage(operation, id, msg.args ?? {});
+ const respMsg = await handler.handleMessage(
+ operation,
+ id,
+ msg.args ?? {},
+ );
logger.info(
`native listener: sending success response for ${operation} (${id})`,
);
@@ -400,7 +410,7 @@ export function installNativeWalletListener(): void {
}
};
- qjsOs.setMessageFromHostHandler((m) => onMessage(m))
+ qjsOs.setMessageFromHostHandler((m) => onMessage(m));
logger.info("native wallet listener installed");
}