line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!perl |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
|
4
|
3
|
|
|
3
|
|
1999
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
111
|
|
5
|
3
|
|
|
3
|
|
11
|
use warnings; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
275
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Log::Any::Adapter::Carp; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our ($VERSION) = '1.02'; |
10
|
|
|
|
|
|
|
our (@CARP_NOT) = ( __PACKAGE__, 'Log::Any::Proxy' ); |
11
|
|
|
|
|
|
|
|
12
|
3
|
|
|
3
|
|
15
|
use Scalar::Util qw(reftype); |
|
3
|
|
|
|
|
2
|
|
|
3
|
|
|
|
|
271
|
|
13
|
3
|
|
|
3
|
|
15
|
use Log::Any::Adapter::Util 1; |
|
3
|
|
|
|
|
51
|
|
|
3
|
|
|
|
|
106
|
|
14
|
|
|
|
|
|
|
|
15
|
3
|
|
|
3
|
|
1432
|
use parent 'Log::Any::Adapter::Base'; |
|
3
|
|
|
|
|
858
|
|
|
3
|
|
|
|
|
12
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub init { |
18
|
16
|
|
|
16
|
0
|
9662
|
my ($self) = @_; |
19
|
16
|
|
|
|
|
22
|
my $i = 1; |
20
|
16
|
|
|
|
|
17
|
my $callpack; |
21
|
|
|
|
|
|
|
my $logger; |
22
|
|
|
|
|
|
|
|
23
|
16
|
|
|
|
|
15
|
do { $callpack = caller( $i++ ) } while $callpack =~ /^Log::Any::/; |
|
76
|
|
|
|
|
240
|
|
24
|
|
|
|
|
|
|
|
25
|
16
|
50
|
|
|
|
49
|
$self->{log_level} = 'trace' unless exists $self->{log_level}; |
26
|
16
|
50
|
|
|
|
93
|
$self->{log_level} = |
27
|
|
|
|
|
|
|
Log::Any::Adapter::Util::numeric_level( $self->{log_level} ) |
28
|
|
|
|
|
|
|
unless $self->{log_level} =~ /^\d+$/; |
29
|
|
|
|
|
|
|
|
30
|
16
|
100
|
100
|
|
|
336
|
if ( $self->{no_trace} ) { |
|
|
100
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$self->{send_msg} = sub { |
32
|
1
|
|
50
|
1
|
|
2
|
my $text = shift || ''; |
33
|
1
|
50
|
|
|
|
3
|
$text .= "\n" unless $text =~ /\n$/; |
34
|
1
|
|
|
|
|
5
|
warn $text; |
35
|
1
|
|
|
|
|
3
|
}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
elsif ( $self->{skip_packages} |
38
|
|
|
|
|
|
|
and reftype( $self->{skip_packages} ) eq 'REGEXP' ) |
39
|
|
|
|
|
|
|
{ |
40
|
6
|
50
|
|
|
|
18
|
my $skipadd = '|^Log::Any::|^Carp::Clan::' |
41
|
|
|
|
|
|
|
. ( $self->{skip_me} ? "|^$callpack\$" : '' ); |
42
|
6
|
|
|
|
|
57
|
my $skipre = qr/$self->{skip_packages}$skipadd/; |
43
|
|
|
|
|
|
|
|
44
|
6
|
|
|
|
|
31
|
require Carp::Clan; |
45
|
|
|
|
|
|
|
{ |
46
|
|
|
|
|
|
|
|
47
|
6
|
|
|
|
|
5
|
package Log::Any::Adapter::Carp::Clannish; |
48
|
6
|
|
|
|
|
24
|
Carp::Clan->import($skipre); |
49
|
|
|
|
|
|
|
} |
50
|
3
|
|
|
3
|
|
770
|
no warnings 'once'; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
824
|
|
51
|
6
|
100
|
|
|
|
835
|
$self->{send_msg} = |
52
|
|
|
|
|
|
|
$self->{full_trace} |
53
|
|
|
|
|
|
|
? *Log::Any::Adapter::Carp::Clannish::cluck |
54
|
|
|
|
|
|
|
: *Log::Any::Adapter::Carp::Clannish::carp; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
else { |
57
|
9
|
|
|
|
|
79
|
require Carp; |
58
|
|
|
|
|
|
|
{ |
59
|
|
|
|
|
|
|
|
60
|
9
|
|
|
|
|
10
|
package Log::Any::Adapter::Carp::Carpish; |
61
|
9
|
|
|
|
|
266
|
Carp->import(qw/ carp cluck /); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
9
|
|
|
|
|
14
|
my @skip_pkgs; |
65
|
9
|
100
|
|
|
|
26
|
push @skip_pkgs, $callpack |
66
|
|
|
|
|
|
|
if $self->{skip_me}; |
67
|
|
|
|
|
|
|
|
68
|
9
|
100
|
|
|
|
34
|
if ( exists $self->{skip_packages} ) { |
69
|
3
|
100
|
|
|
|
48
|
if ( reftype $self->{skip_packages} eq 'ARRAY' ) { |
70
|
1
|
|
|
|
|
2
|
push @skip_pkgs, @{ $self->{skip_packages} }; |
|
1
|
|
|
|
|
4
|
|
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
else { |
73
|
2
|
|
|
|
|
14
|
push @skip_pkgs, $self->{skip_packages}; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
9
|
100
|
|
|
|
34
|
my $carp = |
78
|
|
|
|
|
|
|
$self->{full_trace} |
79
|
|
|
|
|
|
|
? *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
|
|
8
|
local %Carp::Internal; |
87
|
7
|
|
|
|
|
23
|
$Carp::Internal{$_}++ for @skip_pkgs; |
88
|
7
|
|
|
|
|
1279
|
$carp->(@_); |
89
|
|
|
|
|
|
|
} |
90
|
9
|
|
|
|
|
52
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
foreach my $method ( Log::Any::Adapter::Util::logging_methods() ) { |
95
|
3
|
|
|
3
|
|
14
|
no strict 'refs'; |
|
3
|
|
|
|
|
2
|
|
|
3
|
|
|
|
|
284
|
|
96
|
|
|
|
|
|
|
my $method_level = Log::Any::Adapter::Util::numeric_level($method); |
97
|
|
|
|
|
|
|
*{$method} = sub { |
98
|
11
|
|
|
11
|
|
531
|
my $self = shift; |
99
|
11
|
100
|
|
|
|
35
|
return if $method_level > $self->{log_level}; |
100
|
10
|
|
|
|
|
24
|
$self->{send_msg}->(@_); |
101
|
|
|
|
|
|
|
}; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
foreach my $method ( Log::Any::Adapter::Util::detection_methods() ) { |
105
|
3
|
|
|
3
|
|
11
|
no strict 'refs'; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
271
|
|
106
|
|
|
|
|
|
|
my $base = substr( $method, 3 ); |
107
|
|
|
|
|
|
|
my $method_level = Log::Any::Adapter::Util::numeric_level($base); |
108
|
|
|
|
|
|
|
*{$method} = sub { |
109
|
9
|
|
|
9
|
|
1869
|
return !!( $method_level <= $_[0]->{log_level} ); |
110
|
|
|
|
|
|
|
}; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
1; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
__END__ |