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 SCAR 6.9
CC
2
Cov
100%
_create_symlink
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« Enbld/Tutorial.pm ↑ Summary Enbld/Target/Attribute/ArchiveName.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 sub logfile {
12 334 ▶ return $LOGFILE;
Subroutine logfile: called CC=1 SCAR=0.0
Pod undocumented
13 }
14  
15 sub rotate {
16 31 ▶ my ( $pkg, $path ) = @_;
Subroutine rotate: called CC=1 SCAR=0.0
Pod undocumented
17  
18 31 _create_logfile( $path );
19 31 _create_symlink( $path );
20  
21 31 return $LOGFILE;
22 }
23  
24 sub write {
25 212 ▶ my ( $pkg, $msg ) = @_;
Subroutine write: called CC=1 SCAR=0.0
Pod undocumented
26  
27 212 open my $fh, '>>', $LOGFILE;
28 212 print $fh $msg;
29 212 close $fh;
30  
31 212 return $msg;
32 }
33  
34 sub _create_logfile {
35 31 ▶ my $path = shift;
Subroutine _create_logfile: called CC=1 SCAR=0.0
36  
37 31 $LOGFILE = File::Spec->catfile( $path, time . '-' . $$ . '.log' );
38 31 open my $fh, ">", $LOGFILE;
39 31 close $fh;
40 }
41  
42 sub _create_symlink {
43 31 ▶ my $path = shift;
Subroutine _create_symlink: called CC=2 SCAR=6.9
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/Tutorial.pm ↑ Summary Enbld/Target/Attribute/ArchiveName.pm »