File Coverage

blib/lib/Log/ger/Output/FileWriteRotate.pm
Criterion Covered Total %
statement 16 16 100.0
branch 1 2 50.0
condition n/a
subroutine 5 5 100.0
pod 0 2 0.0
total 22 25 88.0


line stmt bran cond sub pod time code
1             package Log::ger::Output::FileWriteRotate;
2              
3             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
4             our $DATE = '2020-03-11'; # DATE
5             our $DIST = 'Log-ger-Output-FileWriteRotate'; # DIST
6             our $VERSION = '0.005'; # VERSION
7              
8 1     1   3611 use strict;
  1         3  
  1         23  
9 1     1   4 use warnings;
  1         2  
  1         189  
10              
11             sub meta {
12             return +{
13 1     1 0 14 v => 2,
14             };
15             }
16              
17             sub get_hooks {
18 1     1 0 16 my %plugin_conf = @_;
19              
20 1         462 require File::Write::Rotate;
21 1         34831 my $fwr = File::Write::Rotate->new(%plugin_conf);
22              
23             return {
24             create_outputter => [
25             __PACKAGE__, # key
26             50, # priority
27             sub { # hook
28 6     6   1684 my %hook_args = @_; # see Log::ger::Manual::Internals/"Arguments passed to hook"
29              
30             my $outputter = sub {
31 2         2734 my ($per_target_conf, $fmsg, $per_msg_conf) = @_;
32 2 50       13 $fwr->write($fmsg, $fmsg =~ /\R\z/ ? "" : "\n");
33 6         19 };
34 6         17 [$outputter];
35 1         75 }],
36             };
37             }
38              
39             1;
40             # ABSTRACT: Log to File::Write::Rotate
41              
42             __END__