Changeset 328ad1c4651498e9673afe731179373986393c5a
- Timestamp:
- 03/09/07 20:31:43
(6 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
| r16d453b |
r328ad1c |
|
| 6 | 6 | use POSIX qw/strftime/; |
|---|
| 7 | 7 | use Fcntl qw/:flock/; |
|---|
| | 8 | use IO::File; |
|---|
| 8 | 9 | use Pod::Usage; |
|---|
| 9 | 10 | |
|---|
| … | … | |
| 416 | 417 | parse_config(); |
|---|
| 417 | 418 | |
|---|
| | 419 | sub 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 | |
|---|
| 418 | 432 | sub zfs_remove_snap($$$) { |
|---|
| 419 | 433 | my ($host, $fs, $snap) = @_; |
|---|
| … | … | |
| 450 | 464 | if($@) { |
|---|
| 451 | 465 | unlink("$store/.$dumpfile"); |
|---|
| | 466 | chomp(my $error = $@); |
|---|
| | 467 | $error =~ s/[\r\n]+/ /gsm; |
|---|
| | 468 | zetaback_log($host, "FAILED[$error] $host:$fs $type\n"); |
|---|
| 452 | 469 | die "zfs_full_backup: failed $@"; |
|---|
| 453 | 470 | } |
|---|
| | 471 | my @st = stat("$store/$dumpfile"); |
|---|
| | 472 | my $size = pretty_size($st[7]); |
|---|
| | 473 | zetaback_log($host, "SUCCESS[$size] $host:$fs $type\n"); |
|---|
| 454 | 474 | } |
|---|
| 455 | 475 | |
|---|