line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Armadito::Agent::Logger::Stderr; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
11041410
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
43
|
|
4
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
56
|
|
5
|
1
|
|
|
1
|
|
3
|
use base 'Armadito::Agent::Logger::Backend'; |
|
1
|
|
|
|
|
34
|
|
|
1
|
|
|
|
|
509
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
4
|
use English qw(-no_match_vars); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
17
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
0
|
|
|
0
|
1
|
|
my ( $class, %params ) = @_; |
11
|
|
|
|
|
|
|
|
12
|
0
|
|
|
|
|
|
my $self = { color => $params{config}->{color}, }; |
13
|
0
|
|
|
|
|
|
bless $self, $class; |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
return $self; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub addMessage { |
19
|
0
|
|
|
0
|
1
|
|
my ( $self, %params ) = @_; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
my $level = $params{level}; |
22
|
0
|
|
|
|
|
|
my $message = $params{message}; |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
my $format; |
25
|
0
|
0
|
|
|
|
|
if ( $self->{color} ) { |
26
|
0
|
0
|
|
|
|
|
if ( $level eq 'warning' ) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
$format = "\033[1;35m[%s] %s\033[0m\n"; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
elsif ( $level eq 'error' ) { |
30
|
0
|
|
|
|
|
|
$format = "\033[1;31m[%s] %s\033[0m\n"; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
elsif ( $level eq 'info' ) { |
33
|
0
|
|
|
|
|
|
$format = "\033[1;34m[%s]\033[0m %s\n"; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
elsif ( $level =~ /^debug/ ) { |
36
|
0
|
|
|
|
|
|
$format = "\033[1;1m[%s]\033[0m %s\n"; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
else { |
40
|
0
|
|
|
|
|
|
$format = "[%s] %s\n"; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
printf STDERR $format, $level, $message; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
__END__ |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 NAME |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Armadito::Agent::Logger::Stderr - A stderr backend for the logger |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 DESCRIPTION |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
This is a stderr-based backend for the logger. It supports coloring based on |
57
|
|
|
|
|
|
|
message level on Unix platforms. |