blib/lib/Log/ger/Output/SimpleFile.pm

filter: Statementstmt 100% 24 / 24 Branchbran 75.0% 6 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 2 totaltotal 90.0% 36 / 40 CC 5 SCAR 8.8
CC
5
Cov
94%
get_hooks
4.0
__ANON__
2.0
__ANON__
1.0
CRAP 2.4
↑ Summary
1 package Log::ger::Output::SimpleFile;
2  
3 2 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
4 2 our $DATE = '2020-03-11'; # DATE
5 2 our $DIST = 'Log-ger-Output-SimpleFile'; # DIST
6 2 our $VERSION = '0.004'; # VERSION
7  
8 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 4 ▶sub meta { +{
Subroutine meta: called CC=1 SCAR=0.0
Pod undocumented
12 4 v => 2,
13 } }
14  
15 4 ▶sub get_hooks {
Subroutine get_hooks: called CC=4 SCAR=13.9
Pod undocumented
16 4 my %plugin_conf = @_;
17  
18 4 my $fh;
19 4 ▶ if (defined(my $path = $plugin_conf{path})) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined(my $path = $plugin_conf{'path'})) { } 2 2 4
elsif ($fh = $plugin_conf{'handle'}) { } 1 1 2
20 2 ▶ open $fh, ">>", $path or die "Can't open log file '$path': $!";
Branch: 1 branch
BranchTrueFalseTotal
open $fh, ">>", $path or die "Can't open log file '${path}': $!" 2 0 2
21 } elsif ($fh = $plugin_conf{handle}) {
22 } else {
23 1 die "Please specify 'path' or 'handle'";
24 }
25  
26 return {
27 create_outputter => [
28 __PACKAGE__, # key
29 50, # priority
30 9 ▶ sub { # hook
Subroutine __ANON__: called CC=1 SCAR=0.0
31 9 my %hook_args = @_; # see Log::ger::Manual::Internals/"Arguments passed to hook"
32  
33 3 ▶ my $outputter = sub {
Subroutine __ANON__: called CC=2 SCAR=7.1
34 3 my ($per_target_conf, $fmsg, $per_msg_conf) = @_;
35 3 ▶ print $fh $fmsg . ($fmsg =~ /\R\z/ ? "" : "\n");
Branch: 1 branch
BranchTrueFalseTotal
$fmsg =~ /\R\z/ ? : 0 3 3
36 3 $fh->flush;
37 9 };
38 9 [$outputter];
39 3 }],
40 };
41 }
42  
43 2 1;
44 # ABSTRACT: Send logs to file
45  
46 __END__
↑ Summary