Enbld/Logger.pm

filter: Statementstmt 100% 32 / 32 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 3 totaltotal 93.4% 43 / 46 CC 2 SCAR 1.8
CC
2
Cov
100%
_create_symlink
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« Enbld/Target/Attribute/DarwinArgument.pm ↑ Summary Enbld/Error.pm »
1 package Enbld::Logger;
2  
3 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 6 ▶use autodie;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 6 our $LOGFILE;
10  
11 334 ▶sub logfile {
Subroutine logfile: called CC=1 SCAR=0.0
Pod undocumented
12 334 return $LOGFILE;
13 }
14  
15 31 ▶sub rotate {
Subroutine rotate: called CC=1 SCAR=0.0
Pod undocumented
16 31 my ( $pkg, $path ) = @_;
17  
18 31 _create_logfile( $path );
19 31 _create_symlink( $path );
20  
21 31 return $LOGFILE;
22 }
23  
24 212 ▶sub write {
Subroutine write: called CC=1 SCAR=0.0
Pod undocumented
25 212 my ( $pkg, $msg ) = @_;
26  
27 212 open my $fh, '>>', $LOGFILE;
28 212 print $fh $msg;
29 212 close $fh;
30  
31 212 return $msg;
32 }
33  
34 31 ▶sub _create_logfile {
Subroutine _create_logfile: called CC=1 SCAR=0.0
35 31 my $path = shift;
36  
37 31 $LOGFILE = File::Spec->catfile( $path, time . '-' . $$ . '.log' );
38 31 open my $fh, ">", $LOGFILE;
39 31 close $fh;
40 }
41  
42 31 ▶sub _create_symlink {
Subroutine _create_symlink: called CC=2 SCAR=6.9
43 31 my $path = shift;
44  
45 31 my $link = File::Spec->catfile( $path, 'latest_build.log' );
46 31 ▶ unlink $link if ( -e $link );
Branch: 1 branch
BranchTrueFalseTotal
if -e $link 1 30 31
47 31 symlink $LOGFILE, $link;
48 }
49  
50 6 1;
« Enbld/Target/Attribute/DarwinArgument.pm ↑ Summary Enbld/Error.pm »