line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dancer::Logger::Pipe; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
67512
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
601
|
|
4
|
2
|
|
|
2
|
|
14
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
59
|
|
5
|
2
|
|
|
2
|
|
10
|
use Carp; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
141
|
|
6
|
2
|
|
|
2
|
|
12
|
use base 'Dancer::Logger::Abstract'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1825
|
|
7
|
2
|
|
|
2
|
|
419423
|
use Dancer::Config 'setting'; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
103
|
|
8
|
2
|
|
|
2
|
|
13
|
use IO::Handle; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
532
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub init { |
13
|
4
|
|
|
4
|
1
|
129366
|
my ($self) = @_; |
14
|
|
|
|
|
|
|
|
15
|
4
|
|
33
|
|
|
15
|
my $pipe = setting('pipe') || croak "Missing pipe settings"; |
16
|
4
|
|
66
|
|
|
489
|
my $command = $pipe->{command} || croak "Missing pipe command setting"; |
17
|
|
|
|
|
|
|
|
18
|
3
|
100
|
|
|
|
17043
|
open( my $fh, '|-', $command) |
19
|
|
|
|
|
|
|
|| croak "Unable to open pipe: $!"; |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
261
|
$fh->autoflush(1); |
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
|
|
524
|
$self->{fh} = $fh; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _log { |
27
|
2
|
|
|
2
|
|
78
|
my ( $self, $level, $message ) = @_; |
28
|
2
|
|
|
|
|
9
|
my $fh = $self->{fh}; |
29
|
|
|
|
|
|
|
|
30
|
2
|
50
|
33
|
|
|
61
|
return unless ref $fh && $fh->opened; |
31
|
|
|
|
|
|
|
|
32
|
2
|
50
|
|
|
|
82
|
$fh->print( $self->format_message( $level => $message ) ) |
33
|
|
|
|
|
|
|
or carp "writing logs to pipe failed: $!"; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
__END__ |