Changeset 328ad1c4651498e9673afe731179373986393c5a

Show
Ignore:
Timestamp:
03/09/07 20:31:43 (7 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1173472303 +0000
git-parent:

[16d453b2dce0fb71ecb9c38313e1818d08a40667]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1173472303 +0000
Message:

Add logging, closes #11

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • zetaback

    r16d453b r328ad1c  
    66use POSIX qw/strftime/; 
    77use Fcntl qw/:flock/; 
     8use IO::File; 
    89use Pod::Usage; 
    910 
     
    416417parse_config(); 
    417418 
     419sub zetaback_log($$;@) { 
     420  my ($host, $mess, @args) = @_; 
     421  my $tf = config_get($host, 'time_format'); 
     422  my $file = config_get($host, 'logfile'); 
     423  my $fileh; 
     424  if(defined($file)) { 
     425    $fileh = IO::File->new(">>$file"); 
     426  } 
     427  $fileh ||= IO::File->new(">&STDERR"); 
     428  printf $fileh "%s: $mess", strftime($tf, localtime(time)), @args; 
     429  $fileh->close(); 
     430} 
     431 
    418432sub zfs_remove_snap($$$) { 
    419433  my ($host, $fs, $snap) = @_; 
     
    450464  if($@) { 
    451465    unlink("$store/.$dumpfile"); 
     466    chomp(my $error = $@); 
     467    $error =~ s/[\r\n]+/ /gsm; 
     468    zetaback_log($host, "FAILED[$error] $host:$fs $type\n"); 
    452469    die "zfs_full_backup: failed $@"; 
    453470  } 
     471  my @st = stat("$store/$dumpfile"); 
     472  my $size = pretty_size($st[7]); 
     473  zetaback_log($host, "SUCCESS[$size] $host:$fs $type\n"); 
    454474} 
    455475