File Coverage

blib/lib/Log/Any/Adapter/Journal.pm
Criterion Covered Total %
statement 19 19 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod 0 2 0.0
total 27 29 93.1


line stmt bran cond sub pod time code
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     1   546 use 5.010;
  1         2  
6 1     1   4 use strict;
  1         0  
  1         16  
7 1     1   12 use warnings;
  1         1  
  1         29  
8              
9 1     1   4 use Log::Any::Adapter::Util qw(logging_methods numeric_level);
  1         1  
  1         48  
10 1     1   403 use parent 'Log::Any::Adapter::Screen';
  1         227  
  1         4  
11 1     1   1880 use Class::Method::Modifiers;
  1         1146  
  1         158  
12              
13             our $VERSION = '0.12';
14              
15             # sub init {
16             # my ($self) = @_;
17             # }
18              
19             # Journal doesn't recognize trace, use debug instead
20 1     1 0 857 sub trace { shift->debug(@_) }
21 1     1 0 268 sub is_trace { shift->is_debug(@_) }
22              
23             # For each of the logging methods exposed by Log::Any, add the level
24             # prefix in angled brackets.
25             for my $method ( grep { !/trace/ } logging_methods ) {
26             my $level = numeric_level( $method );
27              
28             before $method => sub {
29             $_[1] = "<$level>$_[1]" unless $_[0]->{use_color};
30             };
31             }
32              
33             # Log::Any levels Journal levels
34             # 0 emergency 0 emerg
35             # 1 alert 1 alert
36             # 2 critical 2 crit
37             # 3 error 3 err
38             # 4 warning 4 warning
39             # 5 notice 5 notice
40             # 6 info 6 info
41             # 7 debug 7 debug
42             # 8 trace
43              
44             1;
45              
46             __END__