btrbk: bugfix: print aborted subvolumes to transaction log

Print all (deferred) actions to transaction log (file, syslog) in
init_transaction_log(), e.g. ABORTED() in "expand subvolume globs".
pull/286/head
Axel Burri 2019-04-18 16:28:53 +02:00
parent 25f0a76e28
commit a7da44cf2f
1 changed files with 9 additions and 6 deletions

15
btrbk
View File

@ -474,7 +474,7 @@ sub init_transaction_log($$)
WARN "Syslog disabled: $@"; WARN "Syslog disabled: $@";
} }
} }
action("startup", status => "v$VERSION", message => "$VERSION_INFO"); action("DEFERRED", %$_) foreach (@transaction_log);
} }
sub close_transaction_log() sub close_transaction_log()
@ -493,13 +493,15 @@ sub action($@)
{ {
my $type = shift // die; my $type = shift // die;
my $h = { @_ }; my $h = { @_ };
my $time = $h->{time} // time; unless($type eq "DEFERRED") {
$h->{type} = $type; my $time = $h->{time} // time;
$h->{time} = $time; $h->{type} = $type;
$h->{localtime} = timestamp($time, 'debug-iso'); $h->{time} = $time;
$h->{localtime} = timestamp($time, 'debug-iso');
push @transaction_log, $h;
}
print_formatted("transaction", [ $h ], output_format => "tlog", no_header => 1, outfile => $tlog_fh) if($tlog_fh); print_formatted("transaction", [ $h ], output_format => "tlog", no_header => 1, outfile => $tlog_fh) if($tlog_fh);
print_formatted("transaction", [ $h ], output_format => "syslog", no_header => 1) if($syslog_enabled); # dirty hack, this calls syslog() print_formatted("transaction", [ $h ], output_format => "syslog", no_header => 1) if($syslog_enabled); # dirty hack, this calls syslog()
push @transaction_log, $h;
return $h; return $h;
} }
@ -4985,6 +4987,7 @@ MAIN:
INFO "$VERSION_INFO (" . localtime($start_time) . ")"; INFO "$VERSION_INFO (" . localtime($start_time) . ")";
action("startup", status => "v$VERSION", message => $VERSION_INFO, time => $start_time);
if($action_diff) if($action_diff)
{ {