gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated: taler-wallet-cli: log observa


From: gnunet
Subject: [taler-wallet-core] branch master updated: taler-wallet-cli: log observability events also for run-until-done
Date: Mon, 22 Apr 2024 20:03:01 +0200

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository wallet-core.

The following commit(s) were added to refs/heads/master by this push:
     new 9596660e6 taler-wallet-cli: log observability events also for 
run-until-done
9596660e6 is described below

commit 9596660e65ea89bbe93aa31cd3d7218f471b54a5
Author: Florian Dold <florian@dold.me>
AuthorDate: Mon Apr 22 20:02:57 2024 +0200

    taler-wallet-cli: log observability events also for run-until-done
---
 packages/taler-wallet-cli/src/index.ts | 41 ++++++++++++++--------------------
 1 file changed, 17 insertions(+), 24 deletions(-)

diff --git a/packages/taler-wallet-cli/src/index.ts 
b/packages/taler-wallet-cli/src/index.ts
index 59be964b2..8c4760223 100644
--- a/packages/taler-wallet-cli/src/index.ts
+++ b/packages/taler-wallet-cli/src/index.ts
@@ -300,6 +300,17 @@ async function createLocalWallet(
   }
 }
 
+function writeObservabilityLog(notif: WalletNotification): void {
+  if (observabilityEventFile) {
+    switch (notif.type) {
+      case NotificationType.RequestObservabilityEvent:
+      case NotificationType.TaskObservabilityEvent:
+        fs.appendFileSync(observabilityEventFile, JSON.stringify(notif) + 
"\n");
+        break;
+    }
+  }
+}
+
 async function withWallet<T>(
   walletCliArgs: WalletCliArgsType,
   f: (ctx: WalletContext) => Promise<T>,
@@ -308,17 +319,7 @@ async function withWallet<T>(
 
   const onNotif = (notif: WalletNotification) => {
     waiter.notify(notif);
-    if (observabilityEventFile) {
-      switch (notif.type) {
-        case NotificationType.RequestObservabilityEvent:
-        case NotificationType.TaskObservabilityEvent:
-          fs.appendFileSync(
-            observabilityEventFile,
-            JSON.stringify(notif) + "\n",
-          );
-          break;
-      }
-    }
+    writeObservabilityLog(notif);
   };
 
   if (walletCliArgs.wallet.walletConnection) {
@@ -366,7 +367,9 @@ async function withLocalWallet<T>(
   walletCliArgs: WalletCliArgsType,
   f: (w: { client: WalletCoreApiClient; ws: Wallet }) => Promise<T>,
 ): Promise<T> {
-  const wh = await createLocalWallet(walletCliArgs);
+  const wh = await createLocalWallet(walletCliArgs, (notif) => {
+    writeObservabilityLog(notif);
+  });
   const w = wh.wallet;
   const res = await f({ client: w.client, ws: w });
   logger.info("Work done, stopping wallet.");
@@ -988,7 +991,7 @@ depositCli
   .requiredArgument("amount", clk.AMOUNT)
   .requiredArgument("targetPayto", clk.STRING)
   .action(async (args) => {
-    await withLocalWallet(args, async (wallet) => {
+    await withWallet(args, async (wallet) => {
       const resp = await wallet.client.call(
         WalletApiOperation.CreateDepositGroup,
         {
@@ -1231,17 +1234,7 @@ advancedCli
     process.on("SIGINT", cleanupSocket);
 
     const onNotif = (notif: WalletNotification) => {
-      if (observabilityEventFile) {
-        switch (notif.type) {
-          case NotificationType.RequestObservabilityEvent:
-          case NotificationType.TaskObservabilityEvent:
-            fs.appendFileSync(
-              observabilityEventFile,
-              JSON.stringify(notif) + "\n",
-            );
-            break;
-        }
-      }
+      writeObservabilityLog(notif);
     };
     const wh = await createLocalWallet(args, onNotif, args.serve.noInit);
     const w = wh.wallet;

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]