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