aboutsummaryrefslogtreecommitdiff
path: root/lib/App/Beam/Backend.pm
blob: 525b57deb118331925e66edca4b820f5f8656894 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package App::Beam::Backend;

use strict;
use Carp;

require Exporter;
our @ISA = qw(Exporter);
use App::Beam::Command qw(:channels);

sub new {
    my $class = shift;
    my $beam = shift or croak "required argument missing";
    return bless { beam => $beam }, $class;
}

sub logger {
    my $self = shift;
    $self->{beam}->logger(@_);
}

sub error {
    my $self = shift;
    $self->{beam}->error(@_);
}

sub debug {
    my $self = shift;
    $self->{beam}->debug(@_);
}

sub abend {
    my $self = shift;
    $self->{beam}->abend(@_);
}

sub dry_run {
    my ($self) = @_;
    return $self->{beam}{dry_run};
}

sub get {
    my $self = shift;
    return $self->{beam}->get(@_);
}

sub isset {
    my $self = shift;
    return $self->{beam}->isset(@_);
}

sub status {
    my $self = shift;
    return $self->{beam}->status(@_);
}

sub logcommand {
    my ($self, $cmd) = @_;
    my $ret = $cmd->status;
    return unless defined $ret;
    my $comname = $cmd->command_name;
    if ($ret) {
	if ($ret == -1) {
	    $self->logger('err', "failed to run $comname");
	} elsif ($ret & 127) {
	    $self->logger('err',
			  "$comname exited on signal " . ($? & 127));
	} elsif (my $e = ($ret >> 8)) {
	    $self->logger('err',
			  "$comname exited with status $e");
	}
	$self->logger('err', "command line was: ".$cmd->command_line);
    }

    my $fd = $cmd->channel(CHAN_STDERR);
    while (<$fd>) {
	chomp;
	$self->logger('err', "[$comname]: $_");
    }
}

sub backup {
    my ($self, $item) = @_;
    $self->error("backup method not implemented",
		 locus => $self->get({variable => [ 'item', $item ],
				      return => '-locus'}));
}

1;

Return to:

Send suggestions and report system problems to the System administrator.