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