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