Log::Agent::Rotate
parameters for logfile rotation
- Provided by: liblog-agent-rotate-perl (Version: 0.104-2)
- Report a bug
parameters for logfile rotation
require Log::Agent::Rotate;
my $policy = Log::Agent::Rotate->make(
-backlog => 7,
-unzipped => 2,
-is_alone => 0,
-max_size => 100_000,
-max_time => "1w",
-file_perm => 0666
);
The "Log::Agent::Rotate" class holds the parameters describing the logfile rotation policy, and is meant to be supplied to instances of "Log::Agent::Driver::File" via arguments in the creation routine, such as "-rotate", or by using array references as values in the "-channels" hashref: See complementary information in Log::Agent::Driver::File.
As rotation cycles are performed, the current logfile is renamed, and possibly compressed, until the maximum backlog is reached, at which time files are deleted. Assuming a backlog of 5 and that the latest 2 files are not compressed, the following files can be present on the filesystem:
logfile # the current logfile
logfile.0 # most recently renamed logfile
logfile.1
logfile.2.gz
logfile.3.gz
logfile.4.gz # oldest logfile, unlinked next cycle
The following switches are available to the creation routine make(), listed in alphabetical order, all taking a single integer value as argument:
Defaults to 7.
Defaults to 0666.
Defaults to false.
Defaults to 1 megabyte.
The value can also be given as a string, postfixed by one of the following letters to specify the period unit (e.g. "3w"):
Letter Unit
------ -------
m minutes
h hours
d days
d days
w weeks
M months (30 days of 24 hours)
y years
Defaults to 0, meaning it is not checked.
Defaults to 0, meaning it is not checked.
Defaults to false, which is always a safe value.
Defaults to 1.
To test whether two configurations are strictly identical, use is_same(), as in:
print "identical\n" if $x->is_same($y);
where both $x and $y are "Log::Agent::Rotate" objects.
All the aforementioned switches also have a corresponding querying routine that can be issued on instances of the class to get their value. It is not possible to modify those attributes.
For instance:
my $x = Log::Agent::Rotate->make(...);
my $mwrite = $x->max_write();
would get the configured max_write threshold.
Originally written by Raphael Manfredi <Raphael_Manfredi@pobox.com>, currently maintained by Mark Rogaski <mrogaski@cpan.org>.
Thanks to Chris Meshkin for his suggestions on file permissions.
Log::Agent(3), Log::Agent::Driver::File(3), Log::Agent::Rotate::File(3).