| 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')
MC/DC0%0/1
setting('pipe') || croak('Missing pipe settings')
setting('pipe')
Truth table50%1/2
A
A= setting('pipe')
| |||||||||||||||||||||||||||||
| 16 | 4 | ▶ | my $command = $pipe->{command} || croak "Missing pipe command setting"; | ||||||||||||||||||||||||||
|
Condition100%2/2
$pipe->{'command'} || croak('Missing pipe command setting')
MC/DC100%1/1
$pipe->{'command'} || croak('Missing pipe command setting')
$pipe->{'command'}
Truth table100%2/2
A
A= $pipe->{'command'}
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 3 | ▶ | open( my $fh, '|-', $command) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
Condition33%1/3
ref $fh and $fh->opened
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
| |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 2 | ▶ | $fh->print( $self->format_message( $level => $message ) ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | or carp "writing logs to pipe failed: $!"; | ||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 3 | 1; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | __END__ | ||||||||||||||||||||||||||||