line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::Dispatch::Pipe; |
2
|
3
|
|
|
3
|
|
82678
|
use 5.008001; |
|
3
|
|
|
|
|
13
|
|
3
|
3
|
|
|
3
|
|
18
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
85
|
|
4
|
3
|
|
|
3
|
|
25
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
186
|
|
5
|
|
|
|
|
|
|
our $VERSION = "0.04"; |
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
2714
|
use Log::Dispatch 2.00; |
|
3
|
|
|
|
|
46723
|
|
|
3
|
|
|
|
|
87
|
|
8
|
3
|
|
|
3
|
|
808
|
use parent 'Log::Dispatch::Output'; |
|
3
|
|
|
|
|
276
|
|
|
3
|
|
|
|
|
20
|
|
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
6135
|
use Scalar::Util qw(openhandle); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1057
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
5
|
|
|
5
|
1
|
31054
|
my ($proto, %params) = @_; |
14
|
5
|
|
33
|
|
|
44
|
my $class = ref $proto || $proto; |
15
|
|
|
|
|
|
|
|
16
|
5
|
|
|
|
|
17
|
my $self = bless {}, $class; |
17
|
5
|
|
|
|
|
60
|
$self->_basic_init(%params); |
18
|
5
|
|
|
|
|
860
|
$self->_init(%params); |
19
|
|
|
|
|
|
|
|
20
|
4
|
|
|
|
|
40
|
$self; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _init { |
24
|
5
|
|
|
5
|
|
18
|
my ($self, %params) = @_; |
25
|
|
|
|
|
|
|
|
26
|
5
|
|
|
|
|
14
|
$self->{output_to} = $params{output_to}; |
27
|
5
|
|
|
|
|
15
|
$self->{binmode} = $params{binmode}; |
28
|
|
|
|
|
|
|
|
29
|
5
|
100
|
|
|
|
27
|
$self->_open_handle if $params{try_at_init}; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _open_handle { |
33
|
4
|
|
|
4
|
|
8
|
my $self = shift; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
open my $fh, '|-', $self->{output_to} |
36
|
4
|
100
|
|
|
|
17078
|
or die "Failed opening pipe: $!"; |
37
|
|
|
|
|
|
|
|
38
|
2
|
|
|
|
|
100
|
my $oldfh = select $fh; |
39
|
2
|
|
|
|
|
45
|
$| = 1; |
40
|
2
|
|
|
|
|
40
|
select $oldfh; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
binmode $fh, $self->{binmode} |
43
|
2
|
100
|
|
|
|
53
|
if $self->{binmode}; |
44
|
|
|
|
|
|
|
|
45
|
2
|
|
|
|
|
9350
|
$fh; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub log_message { |
49
|
3
|
|
|
3
|
0
|
477
|
my ($self, %params) = @_; |
50
|
|
|
|
|
|
|
|
51
|
3
|
|
100
|
|
|
21
|
$self->{fh} ||= $self->_open_handle; |
52
|
|
|
|
|
|
|
|
53
|
2
|
|
|
|
|
8
|
my $fh = $self->{fh}; |
54
|
2
|
|
|
|
|
130
|
print $fh $params{message}; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub DESTROY { |
58
|
5
|
|
|
5
|
|
4101
|
my $self = shift; |
59
|
5
|
100
|
66
|
|
|
9591
|
close $self->{fh} if $self->{fh} and openhandle($self->{fh}); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
__END__ |