line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Cinnamon::Logger; |
2
|
3
|
|
|
3
|
|
17
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
62
|
|
3
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
70
|
|
4
|
3
|
|
|
3
|
|
430
|
use parent qw(Exporter); |
|
3
|
|
|
|
|
270
|
|
|
3
|
|
|
|
|
30
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
1760
|
use Term::ANSIColor (); |
|
3
|
|
|
|
|
17875
|
|
|
3
|
|
|
|
|
134
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
32
|
use Cinnamon::Config; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
536
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @EXPORT = qw( |
11
|
|
|
|
|
|
|
log |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my %COLOR = ( |
15
|
|
|
|
|
|
|
success => 'green', |
16
|
|
|
|
|
|
|
error => 'red', |
17
|
|
|
|
|
|
|
info => 'white', |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub log ($$) { |
21
|
1
|
|
|
1
|
0
|
12007
|
my ($type, $message) = @_; |
22
|
1
|
|
33
|
|
|
10
|
my $color ||= $COLOR{$type}; |
23
|
|
|
|
|
|
|
|
24
|
1
|
50
|
|
|
|
10
|
$message = Term::ANSIColor::colored $message, $color if $color; |
25
|
1
|
|
|
|
|
54
|
$message .= "\n"; |
26
|
|
|
|
|
|
|
|
27
|
1
|
50
|
|
|
|
6
|
my $fh = $type eq 'error' ? *STDERR : *STDOUT; |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
59
|
print $fh $message; |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
6
|
return; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
!!1; |