
It's ~25% of our logfile. This feature was made so you can theoretically do a replay of the log, which requires knowing which plugins were active when. But I don't think anyone's actually doing that because it also requires other info that isn't logged.
45 lines
1.1 KiB
Perl
45 lines
1.1 KiB
Perl
#!perl
|
|
|
|
my $filename = ".revbank.log";
|
|
|
|
sub _log {
|
|
open my $fh, '>>', $filename or warn "$filename: $!";
|
|
print $fh now(), " ", @_, "\n";
|
|
close $fh or warn "$filename: $!";
|
|
}
|
|
|
|
my %buffer;
|
|
sub hook_abort(@) {
|
|
_log("ABORT");
|
|
}
|
|
sub hook_prompt($class, $cart, $prompt, @) {
|
|
$buffer{prompt} = $prompt;
|
|
}
|
|
|
|
sub hook_input($class, $cart, $input, $split_input, @) {
|
|
$input //= "(UNDEF)";
|
|
_log("PROMPT $buffer{prompt} >> $input");
|
|
}
|
|
|
|
sub hook_reject($class, $plugin, $reason, $abort, @) {
|
|
_log("REJECT [$plugin] $reason");
|
|
}
|
|
|
|
sub hook_retry($class, $plugin, $reason, $abort, @) {
|
|
_log("RETRY [$plugin] $reason");
|
|
}
|
|
|
|
sub hook_user_created($class, $username, @) {
|
|
_log("NEWUSER $username");
|
|
}
|
|
|
|
sub hook_user_balance($class, $user, $old, $delta, $new, $transaction_id, @) {
|
|
my $lost = $delta < 0 ? "lost" : "got";
|
|
$delta = $delta->abs;
|
|
$_ = $_->string("+") for $old, $new;
|
|
_log("BALANCE $transaction_id $user had $old, $lost $delta, now has $new");
|
|
}
|
|
|
|
sub hook_checkout($class, $cart, $username, $transaction_id, @) {
|
|
_log("CHECKOUT $transaction_id $_") for map $_->as_loggable, $cart->entries;
|
|
}
|