line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Anego::Logger; |
2
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
19
|
|
4
|
1
|
|
|
1
|
|
3
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
5
|
1
|
|
|
1
|
|
24
|
use parent qw/ Exporter /; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
10
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
430
|
use Term::ANSIColor qw/ colored /; |
|
1
|
|
|
|
|
6949
|
|
|
1
|
|
|
|
|
2123
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @EXPORT = qw/ infof warnf errorf /; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use constant { |
12
|
1
|
|
|
|
|
285
|
INFO => 1, |
13
|
|
|
|
|
|
|
WARN => 2, |
14
|
|
|
|
|
|
|
ERROR => 3, |
15
|
1
|
|
|
1
|
|
8
|
}; |
|
1
|
|
|
|
|
1
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $COLORS = { |
18
|
|
|
|
|
|
|
INFO, => 'cyan', |
19
|
|
|
|
|
|
|
WARN, => 'yellow', |
20
|
|
|
|
|
|
|
ERROR, => 'red', |
21
|
|
|
|
|
|
|
}; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _print { |
24
|
0
|
|
|
0
|
|
|
my ($type, $string, @args) = @_; |
25
|
|
|
|
|
|
|
|
26
|
0
|
0
|
|
|
|
|
my $message = sprintf($string, (map { defined($_) ? $_ : '-' } @args)); |
|
0
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $colored_message = defined $COLORS->{$type} |
28
|
0
|
0
|
|
|
|
|
? colored $message, $COLORS->{$type} |
29
|
|
|
|
|
|
|
: $message; |
30
|
|
|
|
|
|
|
|
31
|
0
|
0
|
0
|
|
|
|
my $fh = $type && $type <= INFO ? *STDOUT : *STDERR; |
32
|
0
|
|
|
|
|
|
print {$fh} $colored_message; |
|
0
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
0
|
0
|
|
sub infof { _print(INFO, @_) } |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
0
|
0
|
|
sub warnf { _print(WARN, @_) } |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub errorf { |
40
|
0
|
|
|
0
|
0
|
|
_print(ERROR, @_); |
41
|
0
|
|
|
|
|
|
exit 1; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |