| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
25
|
|
|
25
|
|
886379
|
use 5.008001; |
|
|
25
|
|
|
|
|
237
|
|
|
2
|
25
|
|
|
25
|
|
133
|
use strict; |
|
|
25
|
|
|
|
|
52
|
|
|
|
25
|
|
|
|
|
714
|
|
|
3
|
25
|
|
|
25
|
|
128
|
use warnings; |
|
|
25
|
|
|
|
|
57
|
|
|
|
25
|
|
|
|
|
1466
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Log::Any; |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: Bringing loggers and listeners together |
|
8
|
|
|
|
|
|
|
our $VERSION = '1.716'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
25
|
|
|
25
|
|
10120
|
use Log::Any::Manager; |
|
|
25
|
|
|
|
|
59
|
|
|
|
25
|
|
|
|
|
739
|
|
|
11
|
25
|
|
|
25
|
|
10069
|
use Log::Any::Proxy::Null; |
|
|
25
|
|
|
|
|
86
|
|
|
|
25
|
|
|
|
|
1114
|
|
|
12
|
25
|
|
|
|
|
8647
|
use Log::Any::Adapter::Util qw( |
|
13
|
|
|
|
|
|
|
require_dynamic |
|
14
|
|
|
|
|
|
|
detection_aliases |
|
15
|
|
|
|
|
|
|
detection_methods |
|
16
|
|
|
|
|
|
|
log_level_aliases |
|
17
|
|
|
|
|
|
|
logging_aliases |
|
18
|
|
|
|
|
|
|
logging_and_detection_methods |
|
19
|
|
|
|
|
|
|
logging_methods |
|
20
|
25
|
|
|
25
|
|
179
|
); |
|
|
25
|
|
|
|
|
51
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# This is overridden in Log::Any::Test |
|
23
|
|
|
|
|
|
|
our $OverrideDefaultAdapterClass; |
|
24
|
|
|
|
|
|
|
our $OverrideDefaultProxyClass; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# singleton and accessor |
|
27
|
|
|
|
|
|
|
{ |
|
28
|
|
|
|
|
|
|
my $manager = Log::Any::Manager->new(); |
|
29
|
212
|
|
|
212
|
|
638
|
sub _manager { return $manager } |
|
30
|
3
|
|
|
3
|
0
|
11
|
sub has_consumer { $manager->has_consumer } |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub import { |
|
34
|
38
|
|
|
38
|
|
362
|
my $class = shift; |
|
35
|
38
|
|
|
|
|
87
|
my $caller = caller(); |
|
36
|
|
|
|
|
|
|
|
|
37
|
38
|
|
|
|
|
110
|
my @export_params = ( $caller, @_ ); |
|
38
|
38
|
|
|
|
|
118
|
$class->_export_to_caller(@export_params); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _export_to_caller { |
|
42
|
38
|
|
|
38
|
|
70
|
my $class = shift; |
|
43
|
38
|
|
|
|
|
61
|
my $caller = shift; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Parse parameters passed to 'use Log::Any' |
|
46
|
38
|
|
|
|
|
137
|
my $saw_log_param; |
|
47
|
|
|
|
|
|
|
my @params; |
|
48
|
38
|
|
|
|
|
146
|
while ( my $param = shift @_ ) { |
|
49
|
23
|
100
|
66
|
|
|
181
|
if ( !$saw_log_param && $param =~ /^\$(\w+)/ ) { |
|
50
|
17
|
|
|
|
|
63
|
$saw_log_param = $1; # defer until later |
|
51
|
17
|
|
|
|
|
59
|
next; # singular |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
else { |
|
54
|
6
|
|
|
|
|
34
|
push @params, $param, shift @_; # pairwise |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
38
|
50
|
|
|
|
164
|
unless ( @params % 2 == 0 ) { |
|
59
|
0
|
|
|
|
|
0
|
require Carp; |
|
60
|
0
|
|
|
|
|
0
|
Carp::croak("Argument list not balanced: @params"); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# get logger if one was requested |
|
64
|
38
|
100
|
|
|
|
5742
|
if ( defined $saw_log_param ) { |
|
65
|
25
|
|
|
25
|
|
240
|
no strict 'refs'; |
|
|
25
|
|
|
|
|
88
|
|
|
|
25
|
|
|
|
|
3082
|
|
|
66
|
17
|
|
|
|
|
47
|
my $proxy = $class->get_logger( category => $caller, @params ); |
|
67
|
17
|
|
|
|
|
53
|
my $varname = "${caller}::${saw_log_param}"; |
|
68
|
17
|
|
|
|
|
15484
|
*$varname = \$proxy; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub get_logger { |
|
73
|
64
|
|
|
64
|
0
|
7434
|
my ( $class, %params ) = @_; |
|
74
|
25
|
|
|
25
|
|
190
|
no warnings 'once'; |
|
|
25
|
|
|
|
|
59
|
|
|
|
25
|
|
|
|
|
8714
|
|
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my $category = |
|
77
|
64
|
100
|
|
|
|
235
|
defined $params{category} ? delete $params{'category'} : caller; |
|
78
|
64
|
100
|
|
|
|
184
|
if ( my $default = delete $params{'default_adapter'} ) { |
|
79
|
4
|
|
|
|
|
7
|
my @default_adapter_params = (); |
|
80
|
4
|
100
|
|
|
|
16
|
if (ref $default eq 'ARRAY') { |
|
81
|
1
|
|
|
|
|
2
|
($default, @default_adapter_params) = @{ $default }; |
|
|
1
|
|
|
|
|
5
|
|
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
# Every default adapter is set only for a given logger category. |
|
84
|
|
|
|
|
|
|
# When another adapter is configured (by using |
|
85
|
|
|
|
|
|
|
# Log::Any::Adapter->set) for this category, it takes |
|
86
|
|
|
|
|
|
|
# precedence, but if that adapter is later removed, the default |
|
87
|
|
|
|
|
|
|
# we set here takes over again. |
|
88
|
|
|
|
|
|
|
$class->_manager->set_default( |
|
89
|
4
|
|
|
|
|
51
|
$category, $default, @default_adapter_params |
|
90
|
|
|
|
|
|
|
); |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
64
|
|
|
|
|
262
|
my $proxy_class = $class->_get_proxy_class( delete $params{proxy_class} ); |
|
94
|
|
|
|
|
|
|
|
|
95
|
64
|
|
|
|
|
169
|
my $adapter = $class->_manager->get_adapter( $category ); |
|
96
|
64
|
|
|
|
|
177
|
my $context = $class->_manager->get_context(); |
|
97
|
|
|
|
|
|
|
|
|
98
|
64
|
|
|
|
|
226
|
require_dynamic($proxy_class); |
|
99
|
64
|
|
|
|
|
326
|
return $proxy_class->new( |
|
100
|
|
|
|
|
|
|
%params, adapter => $adapter, category => $category, context => $context |
|
101
|
|
|
|
|
|
|
); |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub _get_proxy_class { |
|
105
|
64
|
|
|
64
|
|
136
|
my ( $self, $proxy_name ) = @_; |
|
106
|
64
|
100
|
|
|
|
186
|
return $Log::Any::OverrideDefaultProxyClass |
|
107
|
|
|
|
|
|
|
if $Log::Any::OverrideDefaultProxyClass; |
|
108
|
37
|
100
|
100
|
|
|
137
|
return "Log::Any::Proxy" if !$proxy_name && _manager->has_consumer; |
|
109
|
13
|
100
|
|
|
|
108
|
return "Log::Any::Proxy::Null" if !$proxy_name; |
|
110
|
3
|
50
|
|
|
|
17
|
my $proxy_class = ( |
|
111
|
|
|
|
|
|
|
substr( $proxy_name, 0, 1 ) eq '+' |
|
112
|
|
|
|
|
|
|
? substr( $proxy_name, 1 ) |
|
113
|
|
|
|
|
|
|
: "Log::Any::Proxy::$proxy_name" |
|
114
|
|
|
|
|
|
|
); |
|
115
|
3
|
|
|
|
|
8
|
return $proxy_class; |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
# For backward compatibility |
|
119
|
|
|
|
|
|
|
sub set_adapter { |
|
120
|
1
|
|
|
1
|
0
|
928
|
my $class = shift; |
|
121
|
1
|
|
|
|
|
3
|
Log::Any->_manager->set(@_); |
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
__END__ |