blib/lib/Dancer/Logger/Pipe.pm

filter: Statementstmt 100% 30 / 30 Branchbran 66.6% 4 / 6 Conditioncond 57.1% 4 / 7 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 85.7% 48 / 56 CC 7 SCAR 10.8
CC
7
Cov
88%
_log
4.8
init
4.0
BEGIN
1.0
CRAP 2.9
↑ Summary
1 package Dancer::Logger::Pipe;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use base 'Dancer::Logger::Abstract';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Dancer::Config 'setting';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use IO::Handle;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 our $VERSION = '0.01';
11  
12 4 ▶sub init {
Subroutine init: called CC=4 SCAR=13.9
Pod documented
13 4 my ($self) = @_;
14  
15 4 ▶ my $pipe = setting('pipe') || croak "Missing pipe settings";
Condition50%1/2
setting('pipe') || croak('Missing pipe settings')
l!l
40
MC/DC0%0/1
setting('pipe') || croak('Missing pipe settings')
setting('pipe')
Truth table50%1/2
A
A= setting('pipe')
Aresult
11
00
16 4 ▶ my $command = $pipe->{command} || croak "Missing pipe command setting";
Condition100%2/2
$pipe->{'command'} || croak('Missing pipe command setting')
l!l
31
MC/DC100%1/1
$pipe->{'command'} || croak('Missing pipe command setting')
$pipe->{'command'}
Truth table100%2/2
A
A= $pipe->{'command'}
Aresult
11
00
17  
18 3 ▶ open( my $fh, '|-', $command)
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "|-", $command or croak("Unable to open pipe: $!") 2 1 3
19 || croak "Unable to open pipe: $!";
20  
21 2 $fh->autoflush(1);
22  
23 2 $self->{fh} = $fh;
24 }
25  
26 2 ▶sub _log {
Subroutine _log: called CC=4 SCAR=15.6
27 2 my ( $self, $level, $message ) = @_;
28 2 my $fh = $self->{fh};
29  
30 2 ▶ return unless ref $fh && $fh->opened;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $fh and $fh->opened 0 2 2
Condition33%1/3
ref $fh and $fh->opened
!ll&&!rl&&r
002
MC/DC0%0/2
ref $fh and $fh->opened
ref $fh $fh->opened
Truth table33%1/3
A and B
A= ref $fhB= $fh->opened
ABresult
0X0
100
111
31  
32 2 ▶ $fh->print( $self->format_message( $level => $message ) )
Branch: 1 branch
BranchTrueFalseTotal
$fh->print($self->format_message($level, $message)) or carp("writing logs to pipe failed: $!") 2 0 2
33 or carp "writing logs to pipe failed: $!";
34 }
35  
36 3 1;
37  
38 __END__
↑ Summary