ger/Plugin/MultilevelLog.pm

filter: Statementstmt 39.5% 17 / 43 Branchbran 10.0% 1 / 10 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 36.3% 4 / 11 Podpod 0.0% 0 / 2 totaltotal 30.5% 22 / 72 CC 9 SCAR 20.5
CC
9
Cov
32%
__ANON__
18.3
get_hooks
9.7
__ANON__
6.0
CRAP 7.7
« ger.pm ↑ Summary ger/Format/MultilevelLog.pm »
1 package Log::ger::Plugin::MultilevelLog;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Log::ger::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
9 1 our $DATE = '2023-12-29'; # DATE
10 1 our $DIST = 'Log-ger'; # DIST
11 1 our $VERSION = '0.042'; # VERSION
12  
13 0 ▶sub meta { +{
Subroutine meta: not called CC=1 SCAR=6.9
Pod undocumented
14 0 v => 2,
15 } }
16  
17 0 ▶sub get_hooks {
Subroutine get_hooks: not called CC=3 SCAR=22.7
Pod undocumented
18 0 my %conf = @_;
19  
20 0 ▶ my $sub_name = $conf{sub_name} || 'log';
Condition0%0/2
$conf{'sub_name'} || 'log'
l!l
00
MC/DC0%0/1
$conf{'sub_name'} || 'log'
$conf{'sub_name'}
Truth table0%0/2
A
A= $conf{'sub_name'}
Aresult
11
00
21 0 ▶ my $method_name = $conf{method_name} || 'log';
Condition0%0/2
$conf{'method_name'} || 'log'
l!l
00
MC/DC0%0/1
$conf{'method_name'} || 'log'
$conf{'method_name'}
Truth table0%0/2
A
A= $conf{'method_name'}
Aresult
11
00
22  
23 return {
24 create_filter => [
25 __PACKAGE__, # key
26 50, # priority
27 0 ▶ sub { # hook
Subroutine __ANON__: not called CC=1 SCAR=6.9
28 0 my %hook_args = @_; # see Log::ger::Manual::Internals/"Arguments passed to hook"
29  
30 0 ▶ my $filter = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
31 0 my $level = Log::ger::Util::numeric_level(shift);
32 0 ▶ return 0 unless $level <= $Log::ger::Current_Level;
Branch: 1 branch
BranchTrueFalseTotal
unless $level <= $Log::ger::Current_Level 0 0 0
33 0 {level=>$level};
34 0 };
35  
36 0 [$filter, 0, 'ml'];
37 },
38 ],
39  
40 create_formatter => [
41 __PACKAGE__, # key
42 50, # priority
43 0 ▶ sub { # hook
Subroutine __ANON__: not called CC=1 SCAR=4.6
44 0 my %hook_args = @_; # see Log::ger::Manual::Internals/"Arguments passed to hook"
45  
46 my $formatter =
47  
48 # just like the default formatter, except it accepts first
49 # argument (level)
50 0 ▶ sub {
Subroutine __ANON__: not called CC=5 SCAR=29.0
51 0 shift; # level
52 0 ▶ return $_[0] if @_ < 2;
Branch: 1 branch
BranchTrueFalseTotal
if @_ < 2 0 0 0
53 0 my $fmt = shift;
54 0 my @args;
55 0 for (@_) {
56 0 ▶ if (!defined($_)) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $_) { } 0 0 0
elsif (ref $_) { } 0 0 0
57 0 push @args, '<undef>';
58 } elsif (ref $_) {
59 0 push @args, Log::ger::Util::_dump($_);
60 } else {
61 0 push @args, $_;
62 }
63 }
64 # redefine is just a dummy category for perls < 5.22
65 # which don't have 'redundant' yet
66 1 ▶ no warnings ($warnings::Bits{'redundant'} ? 'redundant' : 'redefine');
Subroutine BEGIN: called CC=2 SCAR=7.1
Branch: 1 branch
BranchTrueFalseTotal
$warnings::Bits{'redundant'} ? : 1 0 1
67 0 sprintf $fmt, @args;
68 0 };
69  
70 0 [$formatter, 0, 'ml'];
71 },
72 ],
73  
74 create_routine_names => [
75 __PACKAGE__, # key
76 50, # priority
77 0 ▶ sub { # hook
Subroutine __ANON__: not called CC=1 SCAR=6.9
78 0 my %hook_args = @_; # see Log::ger::Manual::Internals/"Arguments passed to hook"
79 return [{
80 logger_subs => [[$sub_name , undef, 'ml', undef, 'ml']],
81 logger_methods => [[$method_name, undef, 'ml', undef, 'ml']],
82 0 }, $conf{exclusive}];
83 },
84 0 ],
85 };
86 }
87  
88 1 1;
89 # ABSTRACT: (DEPRECATED) Old name for Log::ger::Format::MultilevelLog
90  
91 __END__
« ger.pm ↑ Summary ger/Format/MultilevelLog.pm »