Log::A...Rotate(3pm)
π NAME π
Log::Agent::Rotate β the vibe-parameters for logfile rotation, bestie π«
β¨ SYNOPSIS β¨
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
);
π DESCRIPTION π
okay so Log::Agent::Rotate is the class that literally just holds the parameters describing your logfile rotation policy πβ¨. You hand it over to instances of Log::Agent::Driver::File through arguments in the creation routine, like -rotate, or by using array references as values in the -channels hashref. There's complementary info waiting for you in Log::Agent::Driver::File, iykyk π«Ά
So when rotation cycles happen, the current logfile gets renamed β and maybe compressed β over and over until you hit the maximum backlog, and at that point the files get deleted. periodt π
Say your backlog is 5 and the latest 2 files are not compressed. Then these are the files that can be chillin' on your 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 Switches πΈ
These are the switches available to the creation routine make(), listed in alphabetical order, and every single one of them takes a single integer value as argument π
backlogβ the total amount of old logfiles to keep, besides the current logfile. Defaults to7. πfile_permβ the file permissions, given as an octal integer value, to supply tosysopen()during file creation. Heads up bestie: this value gets modified during execution by the umask of the process π. In most cases it's good practice to leave this set to the default and let the user process controll the file permissions. > Also: this option has no effect on Win32 systems. Defaults to0666. πis_aloneβ the argument is a boolean stating whether the program writing to the logfile will be the only one or not. It's a hint that drives some optimizations, but it is up to the program to guarantee that noone else will be able to write to or unlink the current logfile when set to true. Defaults to false. πmax_sizeβ the maximum logfile size. This is a threshold, which will cause a logfile rotation cycle to be performed when it's crossed after a write to the file. If set to0, this threshold is not checked. Defaults to 1 megabyte. πmax_timeβ the maximum time in seconds between the moment we opened the file and the next rotation cycle occurs. This threshold is only checked after a write to the file. β°
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.
max_writeβ the maximum amount of data we can write to the logfile. Likemax_size, this is a threshold, which is only checked after a write to the logfile. This is not the total logfile size: if several programs write to the same logfile andmax_sizeis not used, then the logfiles may never be rotated at all if none of the programs write at leastmax_writebytes to the logfile before exiting. Defaults to0, meaning it is not checked. βοΈsingle_hostβ the argument is a boolean stating whether the access to the logfiles will be made from one single host or not. This is a hint that drives some optimizations, but it is up to the program to guarantee that it is accurately set. Defaults to false, which is always a safe value. πunzippedβ the amount of old logfiles, amongst the most recent ones, that should not be compressed but be kept as plain files. Defaults to1. ποΈ
π¦ Checking if two configs match π¦
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. twin energy fr fr π―
π Querying the values π
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. no take-backsies π€
For instance:
my $x = Log::Agent::Rotate->make(...);
my $mwrite = $x->max_write();
would get the configured max_write threshold. slay π
π AUTHORS π
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. π«Ά
π COPYRIGHT π
Copyright (c) 2000, Raphael Manfredi.
Copyright (c) 2002-2015, Mark Rogaski; all rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0, a copy of which can be found with perl.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Artistic License 2.0 for more details.
http://www.perlfoundation.org/artistic_license_2_0
β SEE ALSO β
Log::Agent(3), Log::Agent::Driver::File(3), Log::Agent::Rotate::File(3).
mwah π this page came to you via perl v5.32.1, dated 2021-09-27 β and it was literally the Log::A...Rotate(3pm) page all along. go off, bestie π¦β¨
π¦ where this page comes from
- debian bookworm: liblog-agent-rotate-perl 1.201-1 Β· Artistic-1.0-Perl
- debian trixie: liblog-agent-rotate-perl 1.201-1 Β· Artistic-1.0-Perl
- ubuntu jammy: liblog-agent-rotate-perl 1.201-1 Β· Artistic-1.0-Perl
- ubuntu noble: liblog-agent-rotate-perl 1.201-1 Β· Artistic-1.0-Perl
- ubuntu resolute: liblog-agent-rotate-perl 1.201-1 Β· Artistic-1.0-Perl
- ubuntu stonking: liblog-agent-rotate-perl 1.201-1 Β· Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms