line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Logger::Stderr; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
24081665
|
use strict; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
218
|
|
4
|
8
|
|
|
8
|
|
27
|
use warnings; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
263
|
|
5
|
8
|
|
|
8
|
|
28
|
use base 'FusionInventory::Agent::Logger::Backend'; |
|
8
|
|
|
|
|
31
|
|
|
8
|
|
|
|
|
2740
|
|
6
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
34
|
use English qw(-no_match_vars); |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
62
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
17
|
|
|
17
|
1
|
25
|
my ($class, %params) = @_; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $self = { |
13
|
|
|
|
|
|
|
color => $params{config}->{color}, |
14
|
17
|
|
|
|
|
36
|
}; |
15
|
17
|
|
|
|
|
34
|
bless $self, $class; |
16
|
|
|
|
|
|
|
|
17
|
17
|
|
|
|
|
62
|
return $self; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub addMessage { |
21
|
11
|
|
|
11
|
1
|
17
|
my ($self, %params) = @_; |
22
|
|
|
|
|
|
|
|
23
|
11
|
|
|
|
|
12
|
my $level = $params{level}; |
24
|
11
|
|
|
|
|
9
|
my $message = $params{message}; |
25
|
|
|
|
|
|
|
|
26
|
11
|
|
|
|
|
8
|
my $format; |
27
|
11
|
100
|
|
|
|
20
|
if ($self->{color}) { |
28
|
4
|
100
|
|
|
|
16
|
if ($level eq 'warning') { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
29
|
1
|
|
|
|
|
2
|
$format = "\033[1;35m[%s] %s\033[0m\n"; |
30
|
|
|
|
|
|
|
} elsif ($level eq 'error') { |
31
|
1
|
|
|
|
|
4
|
$format = "\033[1;31m[%s] %s\033[0m\n"; |
32
|
|
|
|
|
|
|
} elsif ($level eq 'info') { |
33
|
1
|
|
|
|
|
2
|
$format = "\033[1;34m[%s]\033[0m %s\n"; |
34
|
|
|
|
|
|
|
} elsif ($level =~ /^debug/ ) { |
35
|
1
|
|
|
|
|
2
|
$format = "\033[1;1m[%s]\033[0m %s\n"; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} else { |
38
|
7
|
|
|
|
|
5
|
$format = "[%s] %s\n"; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
11
|
|
|
|
|
35
|
printf STDERR $format, $level, $message; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
__END__ |