line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::ger::Output::FileWriteRotate; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2019-09-10'; # DATE |
4
|
|
|
|
|
|
|
our $VERSION = '0.003'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
3492
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
7
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
154
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub get_hooks { |
10
|
1
|
|
|
1
|
0
|
13
|
my %conf = @_; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
|
|
445
|
require File::Write::Rotate; |
13
|
1
|
|
|
|
|
33662
|
my $fwr = File::Write::Rotate->new(%conf); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
return { |
16
|
|
|
|
|
|
|
create_log_routine => [ |
17
|
|
|
|
|
|
|
__PACKAGE__, 50, |
18
|
|
|
|
|
|
|
sub { |
19
|
6
|
|
|
6
|
|
1770
|
my %args = @_; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $logger = sub { |
22
|
2
|
|
|
|
|
2402
|
my ($ctx, $msg) = @_; |
23
|
2
|
50
|
|
|
|
11
|
$fwr->write($msg, $msg =~ /\R\z/ ? "" : "\n"); |
24
|
6
|
|
|
|
|
116
|
}; |
25
|
6
|
|
|
|
|
17
|
[$logger]; |
26
|
1
|
|
|
|
|
67
|
}], |
27
|
|
|
|
|
|
|
}; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |
31
|
|
|
|
|
|
|
# ABSTRACT: Log to File::Write::Rotate |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
__END__ |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=pod |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=encoding UTF-8 |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 NAME |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Log::ger::Output::FileWriteRotate - Log to File::Write::Rotate |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 VERSION |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
This document describes version 0.003 of Log::ger::Output::FileWriteRotate (from Perl distribution Log-ger-Output-FileWriteRotate), released on 2019-09-10. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 SYNOPSIS |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
use Log::ger::Output FileWriteRotate => ( |
50
|
|
|
|
|
|
|
dir => '/var/log', # required |
51
|
|
|
|
|
|
|
prefix => 'myapp', # required |
52
|
|
|
|
|
|
|
#suffix => '.log', # default is '' |
53
|
|
|
|
|
|
|
size => 25*1024*1024, # default is 10MB, unless period is set |
54
|
|
|
|
|
|
|
histories => 12, # default is 10 |
55
|
|
|
|
|
|
|
#buffer_size => 100, # default is none |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 DESCRIPTION |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
This plugin sends logs to L<File::Write::Rotate> (FWR) object. FWR allows |
61
|
|
|
|
|
|
|
autorotation when logging, meaning you don't need an additional external process |
62
|
|
|
|
|
|
|
to perform log rotation but FWR can perform the rotation itself. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=for Pod::Coverage ^(.+)$ |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 CONFIGURATION |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
These configuration parameters are FWR's. See that module's documentation for |
69
|
|
|
|
|
|
|
more details. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 dir |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 prefix |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 suffix |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 size |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 histories |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 buffer_size |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 HOMEPAGE |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Please visit the project's homepage at L<https://metacpan.org/release/Log-ger-Output-FileWriteRotate>. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 SOURCE |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Source repository is at L<https://github.com/perlancar/perl-Log-ger-Output-FileWriteRotate>. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 BUGS |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Log-ger-Output-FileWriteRotate> |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
96
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
97
|
|
|
|
|
|
|
feature. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 SEE ALSO |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
L<Log::ger> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
L<File::Write::Rotate> |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
L<Log::ger::Output::SimpleFile> |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
L<Log::ger::Output::File> |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
L<Log::ger::Output::DirWriteRotate> |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 AUTHOR |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
perlancar <perlancar@cpan.org> |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
This software is copyright (c) 2019, 2017 by perlancar@cpan.org. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
120
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |