btrbk: add function WARN_ONCE

pull/106/merge
Axel Burri 2016-05-10 15:50:33 +02:00
parent edffbd4af9
commit 079b947cd6
1 changed files with 7 additions and 0 deletions

7
btrbk
View File

@ -212,6 +212,7 @@ my $current_transaction;
my @transaction_log; my @transaction_log;
my %config_override; my %config_override;
my @tm_now; # current localtime ( sec, min, hour, mday, mon, year, wday, yday, isdst ) my @tm_now; # current localtime ( sec, min, hour, mday, mon, year, wday, yday, isdst )
my %warn_once;
$SIG{__DIE__} = sub { $SIG{__DIE__} = sub {
@ -282,6 +283,12 @@ sub INFO { my $t = shift; print STDERR "$t\n" if($loglevel >= 2); }
sub WARN { my $t = shift; print STDERR "WARNING: $t\n" if($loglevel >= 1); } sub WARN { my $t = shift; print STDERR "WARNING: $t\n" if($loglevel >= 1); }
sub ERROR { my $t = shift; print STDERR "ERROR: $t\n"; } sub ERROR { my $t = shift; print STDERR "ERROR: $t\n"; }
sub WARN_ONCE {
my $t = shift;
if($warn_once{$t}) { DEBUG("WARN AGAIN: " . $t); }
else { $warn_once{$t} = 1; WARN($t); }
}
sub VINFO { sub VINFO {
return undef unless($do_dumper); return undef unless($do_dumper);
my $vinfo = shift; my $t = shift || "vinfo"; my $maxdepth = shift // 2; my $vinfo = shift; my $t = shift || "vinfo"; my $maxdepth = shift // 2;