line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::Any::Adapter::Dispatch; |
2
|
2
|
|
|
2
|
|
70220
|
use Log::Any::Adapter::Util qw(make_method); |
|
2
|
|
|
|
|
23887
|
|
|
2
|
|
|
|
|
232
|
|
3
|
2
|
|
|
2
|
|
1543
|
use Log::Dispatch; |
|
2
|
|
|
|
|
32218
|
|
|
2
|
|
|
|
|
59
|
|
4
|
2
|
|
|
2
|
|
80
|
use strict; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
87
|
|
5
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
70
|
|
6
|
2
|
|
|
2
|
|
12
|
use base qw(Log::Any::Adapter::Base); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
2444
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub init { |
11
|
2
|
|
|
2
|
0
|
1612
|
my $self = shift; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# If a dispatcher was not explicitly passed in, create a new one with the passed arguments. |
14
|
|
|
|
|
|
|
# |
15
|
2
|
|
66
|
|
|
25
|
$self->{dispatcher} ||= Log::Dispatch->new(@_); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Delegate logging methods to same methods in dispatcher |
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
foreach my $method ( Log::Any->logging_methods() ) { |
21
|
|
|
|
|
|
|
my $log_dispatch_method = $method; |
22
|
|
|
|
|
|
|
$log_dispatch_method =~ s/trace/debug/; |
23
|
|
|
|
|
|
|
__PACKAGE__->delegate_method_to_slot( 'dispatcher', $method, |
24
|
|
|
|
|
|
|
$log_dispatch_method ); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Delegate detection methods to would_log |
28
|
|
|
|
|
|
|
# |
29
|
|
|
|
|
|
|
foreach my $method ( Log::Any->detection_methods() ) { |
30
|
|
|
|
|
|
|
my $level = substr( $method, 3 ); |
31
|
|
|
|
|
|
|
$level =~ s/trace/debug/; |
32
|
|
|
|
|
|
|
make_method( $method, |
33
|
28
|
|
|
28
|
|
38410
|
sub { my ($self) = @_; return $self->{dispatcher}->would_log($level) } |
|
28
|
|
|
|
|
120
|
|
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
__END__ |