line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
3
|
|
55
|
use 5.008001; |
|
2
|
|
|
|
|
6
|
|
2
|
2
|
|
|
3
|
|
12
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
49
|
|
3
|
2
|
|
|
3
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
123
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Log::Any::Adapter::Stdout; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: Simple adapter for logging to STDOUT |
8
|
|
|
|
|
|
|
our $VERSION = '1.717'; |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
3
|
|
14
|
use Log::Any::Adapter::Util (); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
42
|
|
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
3
|
|
399
|
use Log::Any::Adapter::Base; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
463
|
|
13
|
|
|
|
|
|
|
our @ISA = qw/Log::Any::Adapter::Base/; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $trace_level = Log::Any::Adapter::Util::numeric_level('trace'); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub init { |
18
|
8
|
|
|
8
|
0
|
16
|
my ($self) = @_; |
19
|
8
|
100
|
66
|
|
|
47
|
if ( exists $self->{log_level} && $self->{log_level} =~ /\D/ ) { |
20
|
6
|
|
|
|
|
22
|
my $numeric_level = Log::Any::Adapter::Util::numeric_level( $self->{log_level} ); |
21
|
6
|
100
|
|
|
|
16
|
if ( !defined($numeric_level) ) { |
22
|
1
|
|
|
|
|
6
|
require Carp; |
23
|
1
|
|
|
|
|
206
|
Carp::carp( sprintf 'Invalid log level "%s". Defaulting to "%s"', $self->{log_level}, 'trace' ); |
24
|
|
|
|
|
|
|
} |
25
|
6
|
|
|
|
|
70
|
$self->{log_level} = $numeric_level; |
26
|
|
|
|
|
|
|
} |
27
|
8
|
100
|
|
|
|
24
|
if ( !defined $self->{log_level} ) { |
28
|
3
|
|
|
|
|
8
|
$self->{log_level} = $trace_level; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
foreach my $method ( Log::Any::Adapter::Util::logging_methods() ) { |
33
|
2
|
|
|
2
|
|
15
|
no strict 'refs'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
291
|
|
34
|
|
|
|
|
|
|
my $method_level = Log::Any::Adapter::Util::numeric_level($method); |
35
|
|
|
|
|
|
|
*{$method} = sub { |
36
|
2
|
|
|
2
|
|
40
|
my ( $self, $text ) = @_; |
|
|
|
|
8
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
8
|
|
|
|
37
|
2
|
50
|
|
|
|
21
|
return if $method_level > $self->{log_level}; |
38
|
2
|
|
|
|
|
16
|
print STDOUT "$text\n"; |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
foreach my $method ( Log::Any::Adapter::Util::detection_methods() ) { |
43
|
2
|
|
|
2
|
|
13
|
no strict 'refs'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
286
|
|
44
|
|
|
|
|
|
|
my $base = substr( $method, 3 ); |
45
|
|
|
|
|
|
|
my $method_level = Log::Any::Adapter::Util::numeric_level($base); |
46
|
|
|
|
|
|
|
*{$method} = sub { |
47
|
9
|
|
|
9
|
|
42
|
return !!( $method_level <= $_[0]->{log_level} ); |
48
|
|
|
|
|
|
|
}; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |