From fab19ba6d02d90a4795da9faeb7de85b5e2365a7 Mon Sep 17 00:00:00 2001
From: Juerd Waalboer <juerd@tnx.nl>
Date: Mon, 18 Nov 2024 23:08:26 +0100
Subject: [PATCH] nomoney: add logging

---
 plugins/nomoney | 20 +++++++++++++++-----
 revbank         |  2 +-
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/plugins/nomoney b/plugins/nomoney
index 21265a3..496a87b 100644
--- a/plugins/nomoney
+++ b/plugins/nomoney
@@ -22,23 +22,33 @@ sub _inform($unresolved, $username, $skip_print = 0) {
 	call_hooks("beep");
 
 	say "Not possible:";
+
 	for my $entry ($unresolved->entries) {
 		unless ($skip_print) {
-			my @printable = $entry->as_printable;
-			print $printable[0], "\n";
+			my $line = ($entry->as_printable)[0];
+			say $line;
+
+			$line =~ s/^\s+//;
+			call_hooks("log_info", "nomoney: $line");
 		}
 
 		my $broke_users = $entry->attribute('nomoney_users');
 
 		for my $account (sort keys %$broke_users) {
 			my $balance = RevBank::Users::balance($account);
-
-			printf(
-				"\e[31;1m%s have %s.\e[m (balance: %s)\n",
+			
+			my $m = sprintf(
+				"%s have %s",
 				($account eq $username ? "You don't" : "$account doesn't"),
 				abs($broke_users->{$account}),
+			);
+			my $b = sprintf(
+				"(balance: %s)",
 				($balance < 0 ? "\e[31;1m$balance\e[m" : $balance),
 			);
+
+			say "\e[31;1m$m\e[m $b";
+			call_hooks("log_info", "nomoney: $m $b");
 		}
 	}
 }
diff --git a/revbank b/revbank
index 996f09a..1b67652 100755
--- a/revbank
+++ b/revbank
@@ -17,7 +17,7 @@ use RevBank::Messages;
 use RevBank::Cart;
 use RevBank::Prompt;
 
-our $VERSION = "7.1.0";
+our $VERSION = "7.2.0";
 
 our %HELP1 = (
     "abort" => "Abort the current transaction",