line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BalanceOfPower::Role::Logger; |
2
|
|
|
|
|
|
|
$BalanceOfPower::Role::Logger::VERSION = '0.400115'; |
3
|
13
|
|
|
13
|
|
6120
|
use strict; |
|
13
|
|
|
|
|
31
|
|
|
13
|
|
|
|
|
378
|
|
4
|
13
|
|
|
13
|
|
175
|
use v5.10; |
|
13
|
|
|
|
|
39
|
|
5
|
13
|
|
|
13
|
|
54
|
use Moo::Role; |
|
13
|
|
|
|
|
19
|
|
|
13
|
|
|
|
|
91
|
|
6
|
|
|
|
|
|
|
|
7
|
13
|
|
|
13
|
|
4021
|
use Cwd; |
|
13
|
|
|
|
|
23
|
|
|
13
|
|
|
|
|
3819
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has log_active => ( |
10
|
|
|
|
|
|
|
is => 'rw', |
11
|
|
|
|
|
|
|
default => 1 |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has log_name => ( |
15
|
|
|
|
|
|
|
is => 'rw', |
16
|
|
|
|
|
|
|
default => "bop.log" |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has log_dir => ( |
20
|
|
|
|
|
|
|
is => 'rw', |
21
|
|
|
|
|
|
|
default => sub { getcwd } |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has log_on_stdout => ( |
25
|
|
|
|
|
|
|
is => 'rw', |
26
|
|
|
|
|
|
|
default => 0 |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub log_path |
30
|
|
|
|
|
|
|
{ |
31
|
4705
|
|
|
4705
|
0
|
4784
|
my $self = shift; |
32
|
4705
|
|
|
|
|
147247
|
return $self->log_dir . "/" .$self->log_name; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub log |
36
|
|
|
|
|
|
|
{ |
37
|
4637
|
|
|
4637
|
0
|
4790
|
my $self = shift; |
38
|
4637
|
100
|
|
|
|
10831
|
return if(! $self->log_active); |
39
|
4597
|
|
|
|
|
4713
|
my $message = shift; |
40
|
4597
|
|
|
|
|
17132
|
open(my $log, ">>", $self->log_path); |
41
|
4597
|
|
|
|
|
21390
|
print $log $message . "\n"; |
42
|
4597
|
|
|
|
|
70932
|
close($log); |
43
|
4597
|
50
|
|
|
|
29401
|
if($self->log_on_stdout) |
44
|
|
|
|
|
|
|
{ |
45
|
0
|
|
|
|
|
0
|
print $message . "\n"; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub delete_log |
50
|
|
|
|
|
|
|
{ |
51
|
108
|
|
|
108
|
0
|
161
|
my $self = shift; |
52
|
108
|
|
|
|
|
251
|
unlink $self->log_path; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |