ger/Output/String.pm

filter: Statementstmt 96.5% 28 / 29 Branchbran 50.0% 4 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 2 totaltotal 78.0% 39 / 50 CC 6 SCAR 10.8
CC
6
Cov
82%
__ANON__
4.7
get_hooks
3.1
__ANON__
1.0
CRAP 2.9
« ger/Filter/Code.pm ↑ Summary ger/Plugin.pm »
1 package Log::ger::Output::String;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
7 3 our $DATE = '2023-12-29'; # DATE
8 3 our $DIST = 'Log-ger'; # DIST
9 3 our $VERSION = '0.042'; # VERSION
10  
11 7 ▶sub meta { +{
Subroutine meta: called CC=1 SCAR=0.0
Pod undocumented
12 7 v => 2,
13 } }
14  
15 7 ▶sub get_hooks {
Subroutine get_hooks: called CC=3 SCAR=11.4
Pod undocumented
16 7 my %plugin_conf = @_;
17  
18 7 ▶ $plugin_conf{string} or die "Please specify string";
Branch: 1 branch
BranchTrueFalseTotal
$plugin_conf{"string"} or die "Please specify string" 7 0 7
19  
20 7 my $formatter = $plugin_conf{formatter};
21 7 my $append_newline = $plugin_conf{append_newline};
22 7 ▶ $append_newline = 1 unless defined $append_newline;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $append_newline 7 0 7
23  
24 return {
25 create_outputter => [
26 __PACKAGE__, # key
27 50, # priority
28 159 ▶ sub { # hook
Subroutine __ANON__: called CC=1 SCAR=0.2
29 159 my %hook_args = @_; # see Log::ger::Manual::Internals/"Arguments passed to hook"
30 159 my $level = $hook_args{level};
31 31 ▶ my $outputter = sub {
Subroutine __ANON__: called CC=4 SCAR=15.5
32 31 my ($per_target_conf, $msg, $per_msg_conf) = @_;
33 31 ▶ if ($formatter) {
Branch: 1 branch
BranchTrueFalseTotal
if ($formatter) 0 31 31
34 0 $msg = $formatter->($msg);
35 }
36 31 ${ $plugin_conf{string} } .= $msg;
37 31 ▶ ${ $plugin_conf{string} } .= "\n"
Branch: 1 branch
BranchTrueFalseTotal
unless not $append_newline or $msg =~ /\R\z/ 31 0 31
Condition33%1/3
not $append_newline or $msg =~ /\R\z/
l!l&&r!l&&!r
0031
MC/DC0%0/2
not $append_newline or $msg =~ /\R\z/
not $append_newline $msg =~ /\R\z/
Truth table33%1/3
not(A) or B
A= not $append_newlineB= $msg =~ /\R\z/
ABresult
1X1
011
000
38 unless !$append_newline || $msg =~ /\R\z/;
39 159 };
40 159 [$outputter];
41 7 }],
42 };
43 }
44  
45 3 1;
46 # ABSTRACT: Set output to a string
47  
48 __END__
« ger/Filter/Code.pm ↑ Summary ger/Plugin.pm »