Tie::Handle::FileWriteRotate - Filehandle tie to write to autorotated file with File::Write::Rotate
This document describes version 0.040 of Tie::Handle::FileWriteRotate (from Perl distribution Tie-Handle-FileWriteRotate), released on 2019-06-27.
use Tie::Handle::FileWriteRotate; tie *FH, 'Tie::Handle::FileWriteRotate', dir=>'/some/dir', prefix=>'myapp', size=>25*1024*1024, histories=>5; print FH "Logging a line\n"; print FH "Logging another line\n";
This module ties a filehandle to File::Write::Rotate object.
I first wrote this module to tie STDERR, so that warnings/errors are logged to file instead of terminal (with autorotation, for good behavior).
To log warnings/errors to terminal as well as autorotated file, you can do something like this instead:
my $fwr = File::Write::Rotate->new(...); $SIG{__WARN__} = sub { $fwr->write(~~localtime, " ", $_[0], "\n"); warn $_[0]; }; $SIG{__DIE__} = sub { $fwr->write(~~localtime, " ", $_[0], "\n"); die $_[0]; };
Tie this package to file handle. LIST will be passed to File::Write::Rotate's constructor.
LIST
Please visit the project's homepage at https://metacpan.org/release/Tie-Handle-FileWriteRotate.
Source repository is at https://github.com/perlancar/perl-Tie-Handle-FileWriteRotate.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Tie-Handle-FileWriteRotate
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
File::Write::Rotate
perlancar <perlancar@cpan.org>
This software is copyright (c) 2019, 2017, 2012 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Tie::Handle::FileWriteRotate, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tie::Handle::FileWriteRotate
CPAN shell
perl -MCPAN -e shell install Tie::Handle::FileWriteRotate
For more information on module installation, please visit the detailed CPAN module installation guide.