lib/BalanceOfPower/Role/Logger.pm

filter: Statementstmt 56.6% 17 / 30 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 4 / 8 Podpod 0.0% 0 / 3 totaltotal 46.6% 21 / 45 CC 3 SCAR 15.3
CC
3
Cov
50%
log
12.0
__ANON__
2.0
log_path
2.0
CRAP 4.6
« blib/lib/BalanceOfPower/Commands/EconomicAid.pm ↑ Summary blib/lib/BalanceOfPower/Role/Mapmaker.pm »
1 package BalanceOfPower::Role::Logger;
2 11 $BalanceOfPower::Role::Logger::VERSION = '0.300010';
3 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 11 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 11 ▶use Cwd;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 11 has log_active => (
10 is => 'rw',
11 default => 1
12 );
13  
14 11 has log_name => (
15 is => 'rw',
16 default => "bop.log"
17 );
18  
19 has log_dir => (
20 is => 'rw',
21 0 ▶ default => sub { getcwd }
Subroutine __ANON__: not called CC=1 SCAR=6.9
22 11 );
23  
24 11 has log_on_stdout => (
25 is => 'rw',
26 default => 0
27 );
28  
29 sub log_path
30 {
31 0 ▶ my $self = shift;
Subroutine log_path: not called CC=1 SCAR=6.9
Pod undocumented
32 0 return $self->log_dir . "/" .$self->log_name;
33 }
34  
35 sub log
36 {
37 0 ▶ my $self = shift;
Subroutine log: not called CC=3 SCAR=24.8
Pod undocumented
38 0 ▶ return if(! $self->log_active);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->log_active 0 0 0
39 0 my $message = shift;
40 0 open(my $log, ">>", $self->log_path);
41 0 print $log $message . "\n";
42 0 close($log);
43 0 ▶ if($self->log_on_stdout)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->log_on_stdout) 0 0 0
44 {
45 0 print $message . "\n";
46 }
47 }
48  
49 sub delete_log
50 {
51 0 ▶ my $self = shift;
Subroutine delete_log: not called CC=1 SCAR=6.9
Pod undocumented
52 0 unlink $self->log_path;
53 }
54  
55 11 1;
« blib/lib/BalanceOfPower/Commands/EconomicAid.pm ↑ Summary blib/lib/BalanceOfPower/Role/Mapmaker.pm »