line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Enbld::Logger; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
1634
|
use strict; |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
225
|
|
4
|
6
|
|
|
6
|
|
25
|
use warnings; |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
157
|
|
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
455
|
use autodie; |
|
6
|
|
|
|
|
10781
|
|
|
6
|
|
|
|
|
43
|
|
7
|
6
|
|
|
6
|
|
22530
|
use File::Spec; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
1747
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $LOGFILE; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub logfile { |
12
|
334
|
|
|
334
|
0
|
4587
|
return $LOGFILE; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub rotate { |
16
|
31
|
|
|
31
|
0
|
1536
|
my ( $pkg, $path ) = @_; |
17
|
|
|
|
|
|
|
|
18
|
31
|
|
|
|
|
135
|
_create_logfile( $path ); |
19
|
31
|
|
|
|
|
3833
|
_create_symlink( $path ); |
20
|
|
|
|
|
|
|
|
21
|
31
|
|
|
|
|
4097
|
return $LOGFILE; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub write { |
25
|
212
|
|
|
212
|
0
|
751
|
my ( $pkg, $msg ) = @_; |
26
|
|
|
|
|
|
|
|
27
|
212
|
|
|
|
|
1321
|
open my $fh, '>>', $LOGFILE; |
28
|
212
|
|
|
|
|
44542
|
print $fh $msg; |
29
|
212
|
|
|
|
|
1085
|
close $fh; |
30
|
|
|
|
|
|
|
|
31
|
212
|
|
|
|
|
18140
|
return $msg; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _create_logfile { |
35
|
31
|
|
|
31
|
|
74
|
my $path = shift; |
36
|
|
|
|
|
|
|
|
37
|
31
|
|
|
|
|
572
|
$LOGFILE = File::Spec->catfile( $path, time . '-' . $$ . '.log' ); |
38
|
31
|
|
|
|
|
178
|
open my $fh, ">", $LOGFILE; |
39
|
31
|
|
|
|
|
11470
|
close $fh; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _create_symlink { |
43
|
31
|
|
|
31
|
|
140
|
my $path = shift; |
44
|
|
|
|
|
|
|
|
45
|
31
|
|
|
|
|
363
|
my $link = File::Spec->catfile( $path, 'latest_build.log' ); |
46
|
31
|
100
|
|
|
|
761
|
unlink $link if ( -e $link ); |
47
|
31
|
|
|
|
|
549
|
symlink $LOGFILE, $link; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |