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

filter: Statementstmt 100% 24 / 24 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 97.1% 34 / 35 CC 2 SCAR 2.5
CC
2
Cov
96%
__ANON__
2.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
↑ Summary
1 package Log::Any::Adapter::Journal;
2  
3 # ABSTRACT: Adapter for Log::Any that outputs with a priority prefix that systemd's journal can parse
4  
5 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use Log::Any::Adapter::Util qw(logging_methods numeric_level);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use parent 'Log::Any::Adapter::Screen';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Class::Method::Modifiers;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 our $VERSION = '1.0';
14  
15 # sub init {
16 # my ($self) = @_;
17 # }
18  
19 # For each of the logging methods exposed by Log::Any, add the level
20 # prefix in angled brackets.
21 1 for my $method ( logging_methods ) {
22 9 my $level = numeric_level( $method );
23  
24 # Journal doesn't recognize trace (8), print as debug instead
25 9 ▶ $level = 7 if $level > 7;
Branch: 1 branch
BranchTrueFalseTotal
if $level > 7 1 8 9
26  
27 10 ▶ before $method => sub {
Subroutine __ANON__: called CC=2 SCAR=7.6
28 10 ▶ $_[1] = "<$level>$_[1]" unless $_[0]->{use_color};
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0]{"use_color"} 10 0 10
29 9 };
30 }
31  
32 # Log::Any levels Journal levels
33 # 0 emergency 0 emerg
34 # 1 alert 1 alert
35 # 2 critical 2 crit
36 # 3 error 3 err
37 # 4 warning 4 warning
38 # 5 notice 5 notice
39 # 6 info 6 info
40 # 7 debug 7 debug
41 # 8 trace
42  
43 1 1;
44  
45 __END__
↑ Summary