line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!perl |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
|
4
|
3
|
|
|
3
|
|
1672
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
71
|
|
5
|
3
|
|
|
3
|
|
10
|
use warnings; |
|
3
|
|
|
|
|
2
|
|
|
3
|
|
|
|
|
176
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Log::Any::Adapter::Carp; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our ($VERSION) = '1.03'; |
10
|
|
|
|
|
|
|
our (@CARP_NOT) = ( __PACKAGE__, 'Log::Any::Proxy' ); |
11
|
|
|
|
|
|
|
|
12
|
3
|
|
|
3
|
|
9
|
use Scalar::Util qw(reftype); |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
209
|
|
13
|
3
|
|
|
3
|
|
13
|
use Log::Any::Adapter::Util 1; |
|
3
|
|
|
|
|
57
|
|
|
3
|
|
|
|
|
93
|
|
14
|
|
|
|
|
|
|
|
15
|
3
|
|
|
3
|
|
1218
|
use parent 'Log::Any::Adapter::Base'; |
|
3
|
|
|
|
|
699
|
|
|
3
|
|
|
|
|
12
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub init { |
18
|
16
|
|
|
16
|
0
|
6781
|
my ($self) = @_; |
19
|
16
|
|
|
|
|
18
|
my $i = 1; |
20
|
16
|
|
|
|
|
7
|
my $callpack; |
21
|
|
|
|
|
|
|
my $logger; |
22
|
|
|
|
|
|
|
|
23
|
16
|
|
|
|
|
12
|
do { $callpack = caller( $i++ ) } while $callpack =~ /^Log::Any::/; |
|
76
|
|
|
|
|
171
|
|
24
|
|
|
|
|
|
|
|
25
|
16
|
50
|
|
|
|
32
|
$self->{log_level} = 'trace' unless exists $self->{log_level}; |
26
|
|
|
|
|
|
|
$self->{log_level} = |
27
|
|
|
|
|
|
|
Log::Any::Adapter::Util::numeric_level( $self->{log_level} ) |
28
|
16
|
50
|
|
|
|
58
|
unless $self->{log_level} =~ /^\d+$/; |
29
|
|
|
|
|
|
|
|
30
|
16
|
100
|
100
|
|
|
153
|
if ( $self->{no_trace} ) { |
|
|
100
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$self->{send_msg} = sub { |
32
|
1
|
|
50
|
1
|
|
3
|
my $text = shift || ''; |
33
|
1
|
50
|
|
|
|
3
|
$text .= "\n" unless $text =~ /\n$/; |
34
|
1
|
|
|
|
|
16
|
warn $text; |
35
|
1
|
|
|
|
|
4
|
}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
elsif ( $self->{skip_packages} |
38
|
|
|
|
|
|
|
and reftype( $self->{skip_packages} ) eq 'REGEXP' ) |
39
|
|
|
|
|
|
|
{ |
40
|
|
|
|
|
|
|
my $skipadd = '|^Log::Any::|^Carp::Clan::' |
41
|
6
|
50
|
|
|
|
12
|
. ( $self->{skip_me} ? "|^$callpack\$" : '' ); |
42
|
6
|
|
|
|
|
30
|
my $skipre = qr/$self->{skip_packages}$skipadd/; |
43
|
|
|
|
|
|
|
|
44
|
6
|
|
|
|
|
19
|
require Carp::Clan; |
45
|
|
|
|
|
|
|
{ |
46
|
|
|
|
|
|
|
|
47
|
6
|
|
|
|
|
6
|
package Log::Any::Adapter::Carp::Clannish; |
48
|
6
|
|
|
|
|
11
|
Carp::Clan->import($skipre); |
49
|
|
|
|
|
|
|
} |
50
|
3
|
|
|
3
|
|
712
|
no warnings 'once'; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
675
|
|
51
|
|
|
|
|
|
|
$self->{send_msg} = |
52
|
|
|
|
|
|
|
$self->{full_trace} |
53
|
6
|
100
|
|
|
|
537
|
? *Log::Any::Adapter::Carp::Clannish::cluck |
54
|
|
|
|
|
|
|
: *Log::Any::Adapter::Carp::Clannish::carp; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
else { |
57
|
9
|
|
|
|
|
52
|
require Carp; |
58
|
|
|
|
|
|
|
{ |
59
|
|
|
|
|
|
|
|
60
|
9
|
|
|
|
|
7
|
package Log::Any::Adapter::Carp::Carpish; |
61
|
9
|
|
|
|
|
162
|
Carp->import(qw/ carp cluck /); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
9
|
|
|
|
|
11
|
my @skip_pkgs; |
65
|
|
|
|
|
|
|
push @skip_pkgs, $callpack |
66
|
9
|
100
|
|
|
|
17
|
if $self->{skip_me}; |
67
|
|
|
|
|
|
|
|
68
|
9
|
100
|
|
|
|
14
|
if ( exists $self->{skip_packages} ) { |
69
|
3
|
100
|
|
|
|
24
|
if ( reftype $self->{skip_packages} eq 'ARRAY' ) { |
70
|
1
|
|
|
|
|
1
|
push @skip_pkgs, @{ $self->{skip_packages} }; |
|
1
|
|
|
|
|
2
|
|
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
else { |
73
|
2
|
|
|
|
|
8
|
push @skip_pkgs, $self->{skip_packages}; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $carp = |
78
|
|
|
|
|
|
|
$self->{full_trace} |
79
|
9
|
100
|
|
|
|
21
|
? *Log::Any::Adapter::Carp::Carpish::cluck |
80
|
|
|
|
|
|
|
: *Log::Any::Adapter::Carp::Carpish::carp; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
$self->{send_msg} = sub { |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# Ugh, but this is the only Carp mechanism to keep a package out |
85
|
|
|
|
|
|
|
# of the shortmess if the call is *from* it |
86
|
7
|
|
|
7
|
|
10
|
local %Carp::Internal; |
87
|
7
|
|
|
|
|
14
|
$Carp::Internal{$_}++ for @skip_pkgs; |
88
|
7
|
|
|
|
|
866
|
$carp->(@_); |
89
|
|
|
|
|
|
|
} |
90
|
9
|
|
|
|
|
54
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
foreach my $method ( Log::Any::Adapter::Util::logging_methods() ) { |
95
|
3
|
|
|
3
|
|
11
|
no strict 'refs'; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
235
|
|
96
|
|
|
|
|
|
|
my $method_level = Log::Any::Adapter::Util::numeric_level($method); |
97
|
|
|
|
|
|
|
*{$method} = sub { |
98
|
11
|
|
|
11
|
|
1096
|
my $self = shift; |
99
|
11
|
100
|
|
|
|
25
|
return if $method_level > $self->{log_level}; |
100
|
10
|
|
|
|
|
14
|
$self->{send_msg}->(@_); |
101
|
|
|
|
|
|
|
}; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
foreach my $method ( Log::Any::Adapter::Util::detection_methods() ) { |
105
|
3
|
|
|
3
|
|
10
|
no strict 'refs'; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
242
|
|
106
|
|
|
|
|
|
|
my $base = substr( $method, 3 ); |
107
|
|
|
|
|
|
|
my $method_level = Log::Any::Adapter::Util::numeric_level($base); |
108
|
|
|
|
|
|
|
*{$method} = sub { |
109
|
9
|
|
|
9
|
|
2566
|
return !!( $method_level <= $_[0]->{log_level} ); |
110
|
|
|
|
|
|
|
}; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
1; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
__END__ |