Plugin/Encode.pm

filter: Statementstmt 100% 27 / 27 Branchbran 50.0% 1 / 2 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 7 / 7 Podpod 100% 1 / 1 totaltotal 97.5% 39 / 40 CC 4 SCAR 7.9
CC
4
Cov
97%
install
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.2
« Plugin/Stringify.pm ↑ Summary Plugin/ContextStack.pm »
1 package Log::Any::Plugin::Encode;
2 # ABSTRACT: Output message encoding for log adapters
3 4 $Log::Any::Plugin::Encode::VERSION = '0.012';
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 4 ▶use Encode qw( find_encoding );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 4 ▶use Log::Any::Plugin::Util qw( get_old_method set_new_method );
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13  
14 3 ▶sub install {
Subroutine install: called CC=4 SCAR=13.9
Pod documented
15 3 my ($class, $adapter_class, %args) = @_;
16  
17 3 ▶ my $encoding = $args{encoding} || 'utf8';
Condition100%2/2
$args{'encoding'} || 'utf8'
l!l
12
MC/DC100%1/1
$args{'encoding'} || 'utf8'
$args{'encoding'}
Truth table100%2/2
A
A= $args{'encoding'}
Aresult
11
00
18 3 ▶ my $encoder = find_encoding($encoding) or
Branch: 1 branch
BranchTrueFalseTotal
my $encoder = &find_encoding($encoding) or croak("Could not find encoder for encoding[$encoding], check encoding value for typos, or codec installed") 3 0 3
19 croak "Could not find encoder for encoding[$encoding], check encoding value for typos, or codec installed";
20  
21 3 for my $method_name ( Log::Any->logging_methods() ) {
22 27 my $old_method = get_old_method($adapter_class, $method_name);
23  
24 3 ▶ set_new_method($adapter_class, $method_name, sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
25 3 my $self = shift;
26  
27 3 my @encoded_msgs = map { $encoder->encode($_, Encode::FB_WARN) } @_;
28  
29 3 return $self->$old_method(@encoded_msgs);
30 27 });
31 }
32 }
33  
34  
35 4 1;
36  
37 __END__
« Plugin/Stringify.pm ↑ Summary Plugin/ContextStack.pm »