File Coverage

blib/lib/Log/ger/Output/FileWriteRotate.pm
Criterion Covered Total %
statement 15 15 100.0
branch 1 2 50.0
condition n/a
subroutine 4 4 100.0
pod 0 1 0.0
total 20 22 90.9


line stmt bran cond sub pod time code
1             package Log::ger::Output::FileWriteRotate;
2              
3             our $DATE = '2017-08-02'; # DATE
4             our $VERSION = '0.002'; # VERSION
5              
6 1     1   2575 use strict;
  1         2  
  1         24  
7 1     1   4 use warnings;
  1         2  
  1         130  
8              
9             sub get_hooks {
10 1     1 0 13 my %conf = @_;
11              
12 1         290 require File::Write::Rotate;
13 1         27551 my $fwr = File::Write::Rotate->new(%conf);
14              
15             return {
16             create_log_routine => [
17             __PACKAGE__, 50,
18             sub {
19 6     6   1742 my %args = @_;
20              
21             my $logger = sub {
22 2         1992 my ($ctx, $msg) = @_;
23 2 50       12 $fwr->write($msg, $msg =~ /\R\z/ ? "" : "\n");
24 6         21 };
25 6         15 [$logger];
26 1         67 }],
27             };
28             }
29              
30             1;
31             # ABSTRACT: Log to File::Write::Rotate
32              
33             __END__