blib/lib/Log/Any/Adapter/Dispatch.pm

filter: Statementstmt 100% 30 / 30 Branchbran 50.0% 1 / 2 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 88.8% 40 / 45 CC 3 SCAR 5.4
CC
3
Cov
94%
init
3.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.7
↑ Summary
1 package Log::Any::Adapter::Dispatch;
2 # ABSTRACT: Adapter to use Log::Dispatch with Log::Any
3 2 our $VERSION = '0.08';
4  
5 2 ▶use Log::Any::Adapter::Util qw(make_method);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Log::Dispatch;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use base qw(Log::Any::Adapter::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 ▶sub init {
Subroutine init: called CC=3 SCAR=11.4
Pod undocumented
12 2 my $self = shift;
13  
14 # If a dispatcher was not explicitly passed in, create a new one with the passed arguments.
15 #
16 2 ▶ $_[-2] eq "category" and splice @_, -2, 2;
Branch: 1 branch
BranchTrueFalseTotal
$_[-2] eq "category" and splice @_, -2, 2 2 0 2
17 2 ▶ $self->{dispatcher} ||= Log::Dispatch->new(@_);
Condition66%2/3
$self->{"dispatcher"} ||= "Log::Dispatch"->new(@_)
l!l&&r!l&&!r
110
MC/DC0%0/2
$self->{"dispatcher"} ||= "Log::Dispatch"->new(@_)
$self->{"dispatcher"} "Log::Dispatch"->new(@_)
Truth table66%2/3
A ||= B
A= $self->{"dispatcher"}B= "Log::Dispatch"->new(@_)
ABresult
1X1
011
000
18 }
19  
20 # Delegate logging methods to same methods in dispatcher
21 #
22 2 foreach my $method ( Log::Any->logging_methods() ) {
23 18 my $log_dispatch_method = $method;
24 18 $log_dispatch_method =~ s/trace/debug/;
25 18 __PACKAGE__->delegate_method_to_slot( 'dispatcher', $method,
26 $log_dispatch_method );
27 }
28  
29 # Delegate detection methods to would_log
30 #
31 2 foreach my $method ( Log::Any->detection_methods() ) {
32 18 my $level = substr( $method, 3 );
33 18 $level =~ s/trace/debug/;
34 make_method( $method,
35 56 ▶ sub { my ($self) = @_; return $self->{dispatcher}->would_log($level) }
Subroutine __ANON__: called CC=1 SCAR=0.0
36 18 );
37 }
38  
39 2 1;
40  
41 __END__
↑ Summary