File-Write-Rotate-0.29/0000755000175000017500000000000012611416723012302 5ustar s1s1File-Write-Rotate-0.29/README0000644000175000017500000002720512611416723013170 0ustar s1s1SYNOPSIS use File::Write::Rotate; my $fwr = File::Write::Rotate->new( dir => '/var/log', # required prefix => 'myapp', # required #suffix => '.log', # default is '' size => 25*1024*1024, # default is 10MB, unless period is set histories => 12, # default is 10 #buffer_size => 100, # default is none ); # write, will write to /var/log/myapp.log, automatically rotate old log files # to myapp.log.1 when myapp.log reaches 25MB. will keep old log files up to # myapp.log.12. $fwr->write("This is a line\n"); $fwr->write("This is", " another line\n"); To compressing old log files: $fwr->compress; This is usually done in a separate process, because it potentially takes a long time if the files to compress are large; we are rotating automatically in write() so doing automatic compression too would annoyingly block writer for a potentially long time. DESCRIPTION This module can be used to write to file, usually for logging, that can rotate itself. File will be opened in append mode. By default, locking will be done to avoid conflict when there are multiple writers. Rotation can be done by size (after a certain size is reached), by time (daily/monthly/yearly), or both. I first wrote this module for logging script STDERR output to files (see Tie::Handle::FileWriteRotate). ATTRIBUTES buffer_size => int Get or set buffer size. If set to a value larger than 0, then when a write() failed, instead of dying, the message will be stored in an internal buffer first (a regular Perl array). When the number of items in the buffer exceeds this size, then write() will die upon failure. Otherwise, every write() will try to flush the buffer. Can be used for example when a program runs as superuser/root then temporarily drops privilege to a normal user. During this period, logging can fail because the program cannot lock the lock file or write to the logging directory. Before dropping privilege, the program can set buffer_size to some larger-than-zero value to hold the messages emitted during dropping privilege. The next write() as the superuser/root will succeed and flush the buffer to disk (provided there is no other error condition, of course). path => str (ro) Current file's path. handle => (ro) Current file handle. You should not use this directly, but use write() instead. This attribute is provided for special circumstances (e.g. in hooks, see example in the hook section). hook_before_write => code Will be called by write() before actually writing to filehandle (but after locking is done). Code will be passed ($self, \@msgs, $fh) where @msgs is an array of strings to be written (the contents of buffer, if any, plus arguments passed to write()) and $fh is the filehandle. hook_before_rotate => code Will be called by the rotating routine before actually doing rotating. Code will be passed ($self). This can be used to write a footer to the end of each file, e.g.: # hook_before_rotate my ($self) = @_; my $fh = $self->handle; print $fh "Some footer\n"; Since this hook is indirectly called by write(), locking is already done. hook_after_rotate => code Will be called by the rotating routine after the rotating process. Code will be passed ($self, \@renamed, \@deleted) where @renamed is array of new filenames that have been renamed, @deleted is array of new filenames that have been deleted. hook_after_create => code Will be called by after a new file is created. Code will be passed ($self). This hook can be used to write a header to each file, e.g.: # hook_after_create my ($self) = @_; my $fh $self->handle; print $fh "header\n"; Since this is called indirectly by write(), locking is also already done. binmode => str METHODS $obj = File::Write::Rotate->new(%args) Create new object. Known arguments: * dir => STR (required) Directory to put the files in. * prefix => STR (required) Name of files. The files will be named like the following: will only be given if the period argument is set. If period is set to yearly, will be YYYY (4-digit year). If period is monthly, will be YYYY-MM (4-digit year and 2-digit month). If period is daily, will be YYYY-MM-DD (4-digit year, 2-digit month, and 2-digit day). is either empty string for current file; or .1, .2 and so on for rotated files. .1 is the most recent rotated file, .2 is the next most recent, and so on. An example, with prefix set to myapp: myapp # current file myapp.1 # most recently rotated myapp.2 # the next most recently rotated With prefix set to myapp, period set to monthly, suffix set to .log: myapp.2012-12.log # file name for december 2012 myapp.2013-01.log # file name for january 2013 Like previous, but additionally with size also set (which will also rotate each period file if it exceeds specified size): myapp.2012-12.log # file(s) for december 2012 myapp.2012-12.log.1 myapp.2012-12.log.2 myapp.2013-01.log # file(s) for january 2013 All times will use local time, so you probably want to set TZ environment variable or equivalent methods to set time zone. * suffix => STR (default: '') Suffix to give to file names, usually file extension like .log. See prefix for more details. If you use a yearly period, setting suffix is advised to avoid ambiguity with rotate suffix (for example, is myapp.2012 the current file for year 2012 or file with 2012 rotate suffix?) * size => INT (default: 10*1024*1024) Maximum file size, in bytes, before rotation is triggered. The default is 10MB (10*1024*1024) if period is not set. If period is set, no default for size is provided, which means files will not be rotated for size (only for period). * period => STR Can be set to either daily, monthly, or yearly. If set, will automatically rotate after period change. See prefix for more details. * histories => INT (default: 10) Number of rotated files to keep. After the number of files exceeds this, the oldest one will be deleted. 0 means not to keep any history, 1 means to only keep .1 file, and so on. * buffer_size => INT (default: 0) Set initial value of buffer. See the buffer_size attribute for more information. * lock_mode => STR (default: 'write') Can be set to either none, write, or exclusive. none disables locking and increases write performance, but should only be used when there is only one writer. write acquires and holds the lock for each write. exclusive acquires the lock at object creation and holds it until the the object is destroyed. Lock file is named .lck. Will wait for up to 1 minute to acquire lock, will die if failed to acquire lock. * hook_before_write => CODE * hook_before_rotate => CODE * hook_after_rotate => CODE * hook_after_create => CODE See "ATTRIBUTES". * buffer_size => int * rotate_probability => float (between 0 < x < 1) If set, instruct to only check for rotation under a certain probability, for example if value is set to 0.1 then will only check for rotation 10% of the time. lock_file_path => STR Returns a string representing the complete pathname to the lock file, based on dir and prefix attributes. $fwr->write(@args) Write to file. Will automatically rotate file if period changes or file size exceeds specified limit. When rotating, will only keep a specified number of histories and delete the older ones. Does not append newline so you'll have to do it yourself. $fwr->compress Compress old rotated files and remove the uncompressed originals. Currently uses IO::Compress::Gzip to do the compression. Extension given to compressed file is .gz. Will not lock writers, but will create -compress.pid PID file to prevent multiple compression processes running and to signal the writers to postpone rotation. After compression is finished, will remove the PID file, so rotation can be done again on the next write() if necessary. FAQ Why use autorotating file? Mainly convenience and low maintenance. You no longer need a separate rotator process like the Unix logrotate utility (which when accidentally disabled or misconfigured will cause your logs to stop being rotated and grow indefinitely). What is the downside of using FWR (and LDFR)? Mainly (significant) performance overhead. At (almost) every write(), FWR needs to check file sizes and/or dates for rotation. Under default configuration (where lock_mode is write), it also performs locking on each write() to make it safe to use with multiple processes. Below is a casual benchmark to give a sense of the overhead, tested on my Core i5-2400 3.1GHz desktop: Writing lines in the size of ~ 200 bytes, raw writing to disk (SSD) has the speed of around 3.4mil/s, while using FWR it goes down to around ~13k/s. Using lock_mode none or exclusive, the speed is ~52k/s. However, this is not something you'll notice or need to worry about unless you're writing near that speed. If you need more speed, you can try setting rotate_probability which will cause FWR to only check for rotation probabilistically, e.g. if you set this to 0.1 then checks will only be done in about 1 of 10 writes. This can significantly reduce the overhead and increase write speed several times (e.g. 5-8 times), but understand that this will make the writes "overflow" a bit, e.g. file sizes will exceed for a bit if you do size-based rotation. More suitable if you only do size-based rotation since it is usually okay to exceed sizes for a bit. SEE ALSO Log::Dispatch::FileRotate, which inspires this module. Differences between File::Write::Rotate (FWR) and Log::Dispatch::FileRotate (LDFR) are as follows: * FWR is not part of the Log::Dispatch family. This makes FWR more general to use. For using together with Log::Dispatch/Log4perl, I have also written Log::Dispatch::FileWriteRotate which is a direct (although not a perfect drop-in) replacement for Log::Dispatch::FileRotate. * Secondly, FWR does not use Date::Manip. Date::Manip is relatively large (loading Date::Manip 6.37 equals to loading 34 files and ~ 22k lines; while FWR itself is only < 1k lines!) As a consequence of this, FWR does not support DatePattern; instead, FWR replaces it with a simple daily/monthly/yearly period. * And lastly, FWR supports compressing and rotating compressed old files. Using separate processes like the Unix logrotate utility means having to deal with yet another race condition. FWR takes care of that for you (see the compress() method). You also have the option to do file compression in the same script/process if you want, which is convenient. There is no significant overhead difference between FWR and LDFR (FWR is slightly faster than LDFR on my testing). Tie::Handle::FileWriteRotate and Log::Dispatch::FileWriteRotate, which use this module. File-Write-Rotate-0.29/lib/0000755000175000017500000000000012611416723013050 5ustar s1s1File-Write-Rotate-0.29/lib/File/0000755000175000017500000000000012611416723013727 5ustar s1s1File-Write-Rotate-0.29/lib/File/Write/0000755000175000017500000000000012611416723015021 5ustar s1s1File-Write-Rotate-0.29/lib/File/Write/Rotate.pm0000644000175000017500000006200012611416723016613 0ustar s1s1package File::Write::Rotate; our $DATE = '2015-10-20'; # DATE our $VERSION = '0.29'; # VERSION use 5.010001; use strict; use warnings; # we must not use Log::Any, looping if we are used as log output #use Log::Any '$log'; use Carp; use File::Spec; use IO::Compress::Gzip qw(gzip $GzipError); use Scalar::Util qw(weaken); #use Taint::Runtime qw(untaint is_tainted); use Time::HiRes 'time'; our $Debug; sub new { my $class = shift; my %args0 = @_; my %args; defined($args{dir} = delete $args0{dir}) or croak "Please specify dir"; defined($args{prefix} = delete $args0{prefix}) or croak "Please specify prefix"; $args{suffix} = delete($args0{suffix}) // ""; $args{size} = delete($args0{size}) // 0; $args{period} = delete($args0{period}); if ($args{period}) { $args{period} =~ /\A(daily|day|month|monthly|year|yearly)\z/ or croak "Invalid period, please use daily/monthly/yearly"; } for (map {"hook_$_"} qw(before_rotate after_rotate after_create before_write a)) { next unless $args0{$_}; $args{$_} = delete($args0{$_}); croak "Invalid $_, please supply a coderef" unless ref($args{$_}) eq 'CODE'; } if (!$args{period} && !$args{size}) { $args{size} = 10 * 1024 * 1024; } $args{histories} = delete($args0{histories}) // 10; $args{binmode} = delete($args0{binmode}); $args{buffer_size} = delete($args0{buffer_size}); $args{lock_mode} = delete($args0{lock_mode}) // 'write'; $args{lock_mode} =~ /\A(none|write|exclusive)\z/ or croak "Invalid lock_mode, please use none/write/exclusive"; $args{rotate_probability} = delete($args0{rotate_probability}); if (defined $args{rotate_probability}) { $args{rotate_probability} > 0 && $args{rotate_probability} < 1.0 or croak "Invalid rotate_probability, must be 0 < x < 1"; } if (keys %args0) { croak "Unknown arguments to new(): ".join(", ", sort keys %args0); } $args{_buffer} = []; my $self = bless \%args, $class; $self->{_exclusive_lock} = $self->_get_lock if $self->{lock_mode} eq 'exclusive'; $self; } sub buffer_size { my $self = shift; if (@_) { my $old = $self->{buffer_size}; $self->{buffer_size} = $_[0]; return $old; } else { return $self->{buffer_size}; } } sub handle { my $self = shift; $self->{_fh}; } sub path { my $self = shift; $self->{_fp}; } # file path, without the rotate suffix sub _file_path { my ($self) = @_; # _now is calculated every time we access this method $self->{_now} = time(); my @lt = localtime($self->{_now}); $lt[5] += 1900; $lt[4]++; my $period; if ($self->{period}) { if ($self->{period} =~ /year/i) { $period = sprintf("%04d", $lt[5]); } elsif ($self->{period} =~ /month/) { $period = sprintf("%04d-%02d", $lt[5], $lt[4]); } elsif ($self->{period} =~ /day|daily/) { $period = sprintf("%04d-%02d-%02d", $lt[5], $lt[4], $lt[3]); } } else { $period = ""; } my $path = join( '', $self->{dir}, '/', $self->{prefix}, length($period) ? ".$period" : "", $self->{suffix}, ); if (wantarray) { return ($path, $period); } else { return $path; } } sub lock_file_path { my ($self) = @_; return File::Spec->catfile($self->{dir}, $self->{prefix} . '.lck'); } sub _get_lock { my ($self) = @_; return undef if $self->{lock_mode} eq 'none'; return $self->{_weak_lock} if defined($self->{_weak_lock}); require File::Flock::Retry; my $lock = File::Flock::Retry->lock($self->lock_file_path); $self->{_weak_lock} = $lock; weaken $self->{_weak_lock}; return $lock; } # will return \@files. each entry is [filename without compress suffix, # rotate_suffix (for sorting), period (for sorting), compress suffix (for # renaming back)] sub _get_files { my ($self) = @_; opendir my ($dh), $self->{dir} or do { warn "Can't opendir '$self->{dir}': $!"; return; }; my @files; while (my $e = readdir($dh)) { my $cs = $1 if $e =~ s/(\.gz)\z//; # compress suffix next unless $e =~ /\A\Q$self->{prefix}\E (?:\. (?\d{4}(?:-\d\d(?:-\d\d)?)?) )? \Q$self->{suffix}\E (?:\. (?\d+) )? \z /x; push @files, [ $e, $+{rotate_suffix} // 0, $+{period} // "", $cs // "" ]; } closedir($dh); [ sort { $a->[2] cmp $b->[2] || $b->[1] <=> $a->[1] } @files ]; } # rename (increase rotation suffix) and keep only n histories. note: failure in # rotating should not be fatal, we just warn and return. sub _rotate_and_delete { my ($self, %opts) = @_; my $delete_only = $opts{delete_only}; my $lock = $self->_get_lock; CASE: { my $files = $self->_get_files or last CASE; # is there a compression process in progress? this is marked by the # existence of -compress.pid PID file. # # XXX check validity of PID file, otherwise a stale PID file will always # prevent rotation to be done if (-f "$self->{dir}/$self->{prefix}-compress.pid") { warn "Compression is in progress, rotation is postponed"; last CASE; } $self->{hook_before_rotate}->($self, [map {$_->[0]} @$files]) if $self->{hook_before_rotate}; my @deleted; my @renamed; my $i; my $dir = $self->{dir}; my $rotating_period = @$files ? $files->[-1][2] : undef; for my $f (@$files) { my ($orig, $rs, $period, $cs) = @$f; $i++; #say "DEBUG: is_tainted \$dir? ".is_tainted($dir); #say "DEBUG: is_tainted \$orig? ".is_tainted($orig); #say "DEBUG: is_tainted \$cs? ".is_tainted($cs); # TODO actually, it's more proper to taint near the source (in this # case, _get_files) #untaint \$orig; ($orig) = $orig =~ /(.*)/s; # we use this instead, no module needed if ($i <= @$files - $self->{histories}) { say "DEBUG: Deleting old rotated file $dir/$orig$cs ..." if $Debug; if (unlink "$dir/$orig$cs") { push @deleted, "$orig$cs"; } else { warn "Can't delete $dir/$orig$cs: $!"; } next; } if (!$delete_only && defined($rotating_period) && $period eq $rotating_period) { my $new = $orig; if ($rs) { $new =~ s/\.(\d+)\z/"." . ($1+1)/e; } else { $new .= ".1"; } if ($new ne $orig) { say "DEBUG: Renaming rotated file $dir/$orig$cs -> ". "$dir/$new$cs ..." if $Debug; if (rename "$dir/$orig$cs", "$dir/$new$cs") { push @renamed, "$new$cs"; } else { warn "Can't rename '$dir/$orig$cs' -> '$dir/$new$cs': $!"; } } } } $self->{hook_after_rotate}->($self, \@renamed, \@deleted) if $self->{hook_after_rotate}; } # CASE } sub _open { my $self = shift; my ($fp, $period) = $self->_file_path; open $self->{_fh}, ">>", $fp or die "Can't open '$fp': $!"; if (defined $self->{binmode}) { binmode $self->{_fh}, $self->{binmode} or die "Can't set PerlIO layer on '$fp': $!"; } my $oldfh = select $self->{_fh}; $| = 1; select $oldfh; # set autoflush $self->{_fp} = $fp; $self->{hook_after_create}->($self) if $self->{hook_after_create}; } # (re)open file and optionally rotate if necessary sub _rotate_and_open { my $self = shift; my ($do_open, $do_rotate) = @_; my $fp; my %rotate_params; CASE: { # if instructed, only do rotate some of the time to shave overhead if ($self->{rotate_probability} && $self->{_fh}) { last CASE if rand() > $self->{rotate_probability}; } $fp = $self->_file_path; unless (-e $fp) { $do_open++; $do_rotate++; $rotate_params{delete_only} = 1; last CASE; } # file is not opened yet, open unless ($self->{_fh}) { $self->_open; } # period has changed, rotate if ($self->{_fp} ne $fp) { $do_rotate++; $rotate_params{delete_only} = 1; last CASE; } # check whether size has been exceeded my $inode; if ($self->{size} > 0) { my @st = stat($self->{_fh}); my $size = $st[7]; $inode = $st[1]; if ($size >= $self->{size}) { say "DEBUG: Size of $self->{_fp} is $size, exceeds $self->{size}, rotating ..." if $Debug; $do_rotate++; last CASE; } else { # stat the current file (not our handle _fp) my @st = stat($fp); die "Can't stat '$fp': $!" unless @st; my $finode = $st[1]; # check whether other process has rename/rotate under us (for # example, 'prefix' has been moved to 'prefix.1'), in which case # we need to reopen if (defined($inode) && $finode != $inode) { $do_open++; } } } } # CASE $self->_rotate_and_delete(%rotate_params) if $do_rotate; $self->_open if $do_rotate || $do_open; # (re)open } sub write { my $self = shift; # the buffering implementation is currently pretty naive. it assume any # die() as a write failure and store the message to buffer. # FYI: if privilege is dropped from superuser, the failure is usually at # locking the lock file (permission denied). my @msg = (map( {@$_} @{ $self->{_buffer} } ), @_); eval { my $lock = $self->_get_lock; $self->_rotate_and_open; $self->{hook_before_write}->($self, \@msg, $self->{_fh}) if $self->{hook_before_write}; print { $self->{_fh} } @msg; $self->{_buffer} = []; }; my $err = $@; if ($err) { if (($self->{buffer_size} // 0) > @{ $self->{_buffer} }) { # put message to buffer temporarily push @{ $self->{_buffer} }, [@_]; } else { # buffer is already full, let's dump the buffered + current message # to the die message anyway. die join( "", "Can't write", ( @{ $self->{_buffer} } ? " (buffer is full, " . ~~@{ $self->{_buffer} } . " message(s))" : "" ), ": $err, message(s)=", @msg ); } } } sub compress { my ($self) = shift; require Proc::PID::File; my $lock = $self->_get_lock; my $files_ref = $self->_get_files; my $done_compression = 0; if (@{$files_ref}) { my $pid = Proc::PID::File->new( dir => $self->{dir}, name => "$self->{prefix}-compress", verify => 1, ); my $latest_period = $files_ref->[-1][2]; if ($pid->alive) { warn "Another compression is in progress"; } else { my @tocompress; #use DD; dd $self; for my $file_ref (@{$files_ref}) { my ($orig, $rs, $period, $cs) = @{ $file_ref }; #say "D:compress: orig=<$orig> rs=<$rs> period=<$period> cs=<$cs>"; next if $cs; # already compressed next if !$self->{period} && !$rs; # not old file next if $self->{period} && $period eq $latest_period; # not old file push @tocompress, File::Spec->catfile($self->{dir}, $orig); } if (@tocompress) { for my $file (@tocompress) { gzip($file => "$file.gz") or do { warn "gzip failed: $GzipError\n"; next }; unlink $file; } $done_compression = 1; } } } return $done_compression; } sub DESTROY { my ($self) = @_; # Proc::PID::File's DESTROY seem to create an empty PID file, remove it. unlink "$self->{dir}/$self->{prefix}-compress.pid"; } 1; # ABSTRACT: Write to files that archive/rotate themselves __END__ =pod =encoding UTF-8 =head1 NAME File::Write::Rotate - Write to files that archive/rotate themselves =head1 VERSION This document describes version 0.29 of File::Write::Rotate (from Perl distribution File-Write-Rotate), released on 2015-10-20. =head1 SYNOPSIS use File::Write::Rotate; my $fwr = File::Write::Rotate->new( dir => '/var/log', # required prefix => 'myapp', # required #suffix => '.log', # default is '' size => 25*1024*1024, # default is 10MB, unless period is set histories => 12, # default is 10 #buffer_size => 100, # default is none ); # write, will write to /var/log/myapp.log, automatically rotate old log files # to myapp.log.1 when myapp.log reaches 25MB. will keep old log files up to # myapp.log.12. $fwr->write("This is a line\n"); $fwr->write("This is", " another line\n"); To compressing old log files: $fwr->compress; This is usually done in a separate process, because it potentially takes a long time if the files to compress are large; we are rotating automatically in write() so doing automatic compression too would annoyingly block writer for a potentially long time. =head1 DESCRIPTION This module can be used to write to file, usually for logging, that can rotate itself. File will be opened in append mode. By default, locking will be done to avoid conflict when there are multiple writers. Rotation can be done by size (after a certain size is reached), by time (daily/monthly/yearly), or both. I first wrote this module for logging script STDERR output to files (see L). =for Pod::Coverage ^(file_path|DESTROY)$ =head1 ATTRIBUTES =head2 buffer_size => int Get or set buffer size. If set to a value larger than 0, then when a write() failed, instead of dying, the message will be stored in an internal buffer first (a regular Perl array). When the number of items in the buffer exceeds this size, then write() will die upon failure. Otherwise, every write() will try to flush the buffer. Can be used for example when a program runs as superuser/root then temporarily drops privilege to a normal user. During this period, logging can fail because the program cannot lock the lock file or write to the logging directory. Before dropping privilege, the program can set buffer_size to some larger-than-zero value to hold the messages emitted during dropping privilege. The next write() as the superuser/root will succeed and flush the buffer to disk (provided there is no other error condition, of course). =head2 path => str (ro) Current file's path. =head2 handle => (ro) Current file handle. You should not use this directly, but use write() instead. This attribute is provided for special circumstances (e.g. in hooks, see example in the hook section). =head2 hook_before_write => code Will be called by write() before actually writing to filehandle (but after locking is done). Code will be passed ($self, \@msgs, $fh) where @msgs is an array of strings to be written (the contents of buffer, if any, plus arguments passed to write()) and $fh is the filehandle. =head2 hook_before_rotate => code Will be called by the rotating routine before actually doing rotating. Code will be passed ($self). This can be used to write a footer to the end of each file, e.g.: # hook_before_rotate my ($self) = @_; my $fh = $self->handle; print $fh "Some footer\n"; Since this hook is indirectly called by write(), locking is already done. =head2 hook_after_rotate => code Will be called by the rotating routine after the rotating process. Code will be passed ($self, \@renamed, \@deleted) where @renamed is array of new filenames that have been renamed, @deleted is array of new filenames that have been deleted. =head2 hook_after_create => code Will be called by after a new file is created. Code will be passed ($self). This hook can be used to write a header to each file, e.g.: # hook_after_create my ($self) = @_; my $fh $self->handle; print $fh "header\n"; Since this is called indirectly by write(), locking is also already done. =head2 binmode => str =head1 METHODS =head2 $obj = File::Write::Rotate->new(%args) Create new object. Known arguments: =over =item * dir => STR (required) Directory to put the files in. =item * prefix => STR (required) Name of files. The files will be named like the following: C<< >> will only be given if the C argument is set. If C is set to C, C<< >> will be C (4-digit year). If C is C, C<< >> will be C (4-digit year and 2-digit month). If C is C, C<< >> will be C (4-digit year, 2-digit month, and 2-digit day). C<< >> is either empty string for current file; or C<.1>, C<.2> and so on for rotated files. C<.1> is the most recent rotated file, C<.2> is the next most recent, and so on. An example, with C set to C: myapp # current file myapp.1 # most recently rotated myapp.2 # the next most recently rotated With C set to C, C set to C, C set to C<.log>: myapp.2012-12.log # file name for december 2012 myapp.2013-01.log # file name for january 2013 Like previous, but additionally with C also set (which will also rotate each period file if it exceeds specified size): myapp.2012-12.log # file(s) for december 2012 myapp.2012-12.log.1 myapp.2012-12.log.2 myapp.2013-01.log # file(s) for january 2013 All times will use local time, so you probably want to set C environment variable or equivalent methods to set time zone. =item * suffix => STR (default: '') Suffix to give to file names, usually file extension like C<.log>. See C for more details. If you use a yearly period, setting suffix is advised to avoid ambiguity with rotate suffix (for example, is C the current file for year 2012 or file with C<2012> rotate suffix?) =item * size => INT (default: 10*1024*1024) Maximum file size, in bytes, before rotation is triggered. The default is 10MB (10*1024*1024) I C is not set. If C is set, no default for C is provided, which means files will not be rotated for size (only for period). =item * period => STR Can be set to either C, C, or C. If set, will automatically rotate after period change. See C for more details. =item * histories => INT (default: 10) Number of rotated files to keep. After the number of files exceeds this, the oldest one will be deleted. 0 means not to keep any history, 1 means to only keep C<.1> file, and so on. =item * buffer_size => INT (default: 0) Set initial value of buffer. See the C attribute for more information. =item * lock_mode => STR (default: 'write') Can be set to either C, C, or C. C disables locking and increases write performance, but should only be used when there is only one writer. C acquires and holds the lock for each write. C acquires the lock at object creation and holds it until the the object is destroyed. Lock file is named C<< >>C<.lck>. Will wait for up to 1 minute to acquire lock, will die if failed to acquire lock. =item * hook_before_write => CODE =item * hook_before_rotate => CODE =item * hook_after_rotate => CODE =item * hook_after_create => CODE See L. =item * buffer_size => int =item * rotate_probability => float (between 0 < x < 1) If set, instruct to only check for rotation under a certain probability, for example if value is set to 0.1 then will only check for rotation 10% of the time. =back =head2 lock_file_path => STR Returns a string representing the complete pathname to the lock file, based on C and C attributes. =head2 $fwr->write(@args) Write to file. Will automatically rotate file if period changes or file size exceeds specified limit. When rotating, will only keep a specified number of histories and delete the older ones. Does not append newline so you'll have to do it yourself. =head2 $fwr->compress Compress old rotated files and remove the uncompressed originals. Currently uses L to do the compression. Extension given to compressed file is C<.gz>. Will not lock writers, but will create C<< >>C<-compress.pid> PID file to prevent multiple compression processes running and to signal the writers to postpone rotation. After compression is finished, will remove the PID file, so rotation can be done again on the next C if necessary. =head1 FAQ =head2 Why use autorotating file? Mainly convenience and low maintenance. You no longer need a separate rotator process like the Unix B utility (which when accidentally disabled or misconfigured will cause your logs to stop being rotated and grow indefinitely). =head2 What is the downside of using FWR (and LDFR)? Mainly (significant) performance overhead. At (almost) every C, FWR needs to check file sizes and/or dates for rotation. Under default configuration (where C is C), it also performs locking on each C to make it safe to use with multiple processes. Below is a casual benchmark to give a sense of the overhead, tested on my Core i5-2400 3.1GHz desktop: Writing lines in the size of ~ 200 bytes, raw writing to disk (SSD) has the speed of around 3.4mil/s, while using FWR it goes down to around ~13k/s. Using C C or C, the speed is ~52k/s. However, this is not something you'll notice or need to worry about unless you're writing near that speed. If you need more speed, you can try setting C which will cause FWR to only check for rotation probabilistically, e.g. if you set this to 0.1 then checks will only be done in about 1 of 10 writes. This can significantly reduce the overhead and increase write speed several times (e.g. 5-8 times), but understand that this will make the writes "overflow" a bit, e.g. file sizes will exceed for a bit if you do size-based rotation. More suitable if you only do size-based rotation since it is usually okay to exceed sizes for a bit. =head1 SEE ALSO L, which inspires this module. Differences between File::Write::Rotate (FWR) and Log::Dispatch::FileRotate (LDFR) are as follows: =over =item * FWR is not part of the L family. This makes FWR more general to use. For using together with Log::Dispatch/Log4perl, I have also written L which is a direct (although not a perfect drop-in) replacement for Log::Dispatch::FileRotate. =item * Secondly, FWR does not use L. Date::Manip is relatively large (loading Date::Manip 6.37 equals to loading 34 files and ~ 22k lines; while FWR itself is only < 1k lines!) As a consequence of this, FWR does not support DatePattern; instead, FWR replaces it with a simple daily/monthly/yearly period. =item * And lastly, FWR supports compressing and rotating compressed old files. Using separate processes like the Unix B utility means having to deal with yet another race condition. FWR takes care of that for you (see the compress() method). You also have the option to do file compression in the same script/process if you want, which is convenient. =back There is no significant overhead difference between FWR and LDFR (FWR is slightly faster than LDFR on my testing). L and Log::Dispatch::FileWriteRotate, which use this module. =head1 HOMEPAGE Please visit the project's homepage at L. =head1 SOURCE Source repository is at L. =head1 BUGS Please report any bugs or feature requests on the bugtracker website L 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. =head1 AUTHOR perlancar =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2015 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. =cut File-Write-Rotate-0.29/Makefile.PL0000644000175000017500000000327412611416723014262 0ustar s1s1# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.037. use strict; use warnings; use 5.010001; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "Write to files that archive/rotate themselves", "AUTHOR" => "perlancar ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "File-Write-Rotate", "EXE_FILES" => [], "LICENSE" => "perl", "MIN_PERL_VERSION" => "5.010001", "NAME" => "File::Write::Rotate", "PREREQ_PM" => { "File::Flock::Retry" => 0, "Proc::PID::File" => 0 }, "TEST_REQUIRES" => { "File::Slurp::Tiny" => 0, "File::Spec" => 0, "File::chdir" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Monkey::Patch::Action" => 0, "Taint::Runtime" => 0, "Test::Exception" => "0.31", "Test::More" => "0.98", "Test::Warnings" => "0.014", "tainting" => "0.01" }, "VERSION" => "0.29", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "ExtUtils::MakeMaker" => 0, "File::Flock::Retry" => 0, "File::Slurp::Tiny" => 0, "File::Spec" => 0, "File::chdir" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Monkey::Patch::Action" => 0, "Proc::PID::File" => 0, "Taint::Runtime" => 0, "Test::Exception" => "0.31", "Test::More" => "0.98", "Test::Warnings" => "0.014", "tainting" => "0.01" ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); File-Write-Rotate-0.29/Changes0000644000175000017500000001175612611416723013607 0ustar s1s1Revision history for File-Write-Rotate 0.29 2015-10-20 (PERLANCAR) - No functional changes. - To reduce deps, remove runtime use of Taint::Runtime. 0.28 2015-01-26 (PERLANCAR) - Now check argument to new(), unknown arguments will croak. - Add option: rotate_probability, to increase writing speed by only doing rotate checks probabilistically, at the consequence of writes "spilling" for a bit. 0.27 2015-01-23 (PERLANCAR) - No functional changes. - [Bugfix] Fix compression when logging dir is not the current directory (Jonathan G. Rennison). 0.26 2015-01-22 (PERLANCAR) - Add option: lock_mode (can be set to 'write' [the default] or 'none'/'exclusive'). Setting this option to 'none'/'exclusive' can increase write performance, but setting to 'none' means disabling locking and should be done if you expect only one writer, and setting to 'exclusive' means holding the lock for a long time. (Thanks Jonathan G. Rennison). 0.25 2014-12-05 (PERLANCAR) - No functional changes. - Use new name of renamed module SHARYANTO::File::Flock -> File::Flock::Retry. 0.24 2014-12-05 (PERLANCAR) - These changes are done by TOSHIOITO++. [BUG FIXES] - Make sure lock is released even when write() or some hook dies. - Fix rotation, rotation by period previously never delete old files. [INCOMPATIBLE CHANGES] - compress() method now avoids compressing files with the latest period. Before, this method avoided compressing files with the period of "_cur_period" private attribute, which was set by _open(). However, "_cur_period" was not set if compress() was called without calling write() beforehand. The new behavior is a little different from the old, but it's the same in most cases. 0.23 2014-11-09 (PERLANCAR) - compress() now unlinks uncompressed originals (this is the original behavior before switching from using gzip utility to IO::Compress::Gzip). 0.22 2014-09-01 (PERLANCAR) - No functional changes. - POD fixes. 0.21 2014-09-01 (PERLANCAR) - Introduce hooks (currently: hook_{before_write,after_create,before_rotate,after_rotate}). - Add (ro) attribute methods: handle(), path(). 0.20 2014-08-22 (SHARYANTO) - Bug fix: Set timezone when testing, otherwise in UTC+12 (e.g. Auckland) there is change of day [CT]. 0.19 2014-08-20 (SHARYANTO) - Fix bug in file_path() which caused current period log file to be compressed [problem reported by Alceu Rodrigues de Freitas Junior]. 0.18 2014-08-16 (SHARYANTO) - Happy 19th CPAN Day! [ENHANCEMENTS] - Replace the use of 'gzip' binary with IO::Compress::Gzip, to allow this module to run in OS's other than Unix-like ones [Alceu Rodrigues de Freitas Junior]. - Add tests for compression. [BUG FIXES] - Old period logs were never compressed. 0.17 2014-07-10 (SHARYANTO) - Fix dep version (Test::Warnings 0.014, not 0.14). 0.16 2014-07-10 (SHARYANTO) - Added support for 'binmode' (to set PerlIO layers, esp. encoding) [thanks Norbert Buchmuller]. 0.15 2014-05-17 (SHARYANTO) - No functional changes. - Replace File::Slurp with File::Slurp::Tiny. 0.14 2013-07-03 (SHARYANTO) - No functional changes. Force fixed SHARYANTO::File::Flock version (0.49). 0.13 2013-04-12 (SHARYANTO) - No functional changes. Add FAQ item on why use FWR and the downside. 0.12 2013-04-12 (SHARYANTO) - No functional changes. Update module name in POD and expand the explanation on the difference between FWR & LDFR. 0.11 2012-12-28 (SHARYANTO) - No functional changes. Tweak error message. 0.10 2012-12-28 (SHARYANTO) [NEW FEATURES] - Add buffering (attribute: buffer_size) to buffer messages during temporary write() failure. 0.09 2012-12-28 (SHARYANTO) - Make rotate pass under taint-mode. 0.08 2012-12-28 (SHARYANTO) [BUG FIXES] - Can now rotate on the first write() instead of on the second and subsequent. 0.07 2012-12-27 (SHARYANTO) - Avoid using Log::Any, because we are used as backend for Log::Dispatch::FileWriteRotate (thus, a loop). 0.06 2012-12-27 (SHARYANTO) - Set autoflush (to pass Log-Any-App09 tests). 0.05 2012-12-26 (SHARYANTO) - No functional changes. Mention 'period' argument in POD. 0.04 2012-12-26 (SHARYANTO) - A small fix in DESTROY(). 0.03 2012-12-25 (SHARYANTO) - No functional changes. Extract flocking routines to SHARYANTO::File::Flock. 0.02 2012-12-22 (SHARYANTO) - No functional changes. Additions/corrections for POD. 0.01 2012-12-21 (SHARYANTO) - First release. File-Write-Rotate-0.29/dist.ini0000644000175000017500000000051112611416723013743 0ustar s1s1version = 0.29 name = File-Write-Rotate [@Author::PERLANCAR] :version=0.23 [Prereqs / TestRequires] File::chdir=0 File::Slurp::Tiny=0 Monkey::Patch::Action=0 Taint::Runtime=0 tainting=0.01 Test::Exception=0.31 Test::More=0.98 Test::Warnings=0.014 [Prereqs] perl=5.010001 File::Flock::Retry=0 ;Log::Any=0 Proc::PID::File=0 File-Write-Rotate-0.29/LICENSE0000644000175000017500000004367712611416723013330 0ustar s1s1This software is copyright (c) 2015 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. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2015 by perlancar@cpan.org. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. 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 GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2015 by perlancar@cpan.org. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End File-Write-Rotate-0.29/t/0000755000175000017500000000000012611416723012545 5ustar s1s1File-Write-Rotate-0.29/t/00-compile.t0000644000175000017500000000232012611416723014574 0ustar s1s1use 5.006; use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.053 use Test::More; plan tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0); my @module_files = ( 'File/Write/Rotate.pm' ); # no fake home requested my $inc_switch = -d 'blib' ? '-Mblib' : '-Ilib'; use File::Spec; use IPC::Open3; use IO::Handle; open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; my @warnings; for my $lib (@module_files) { # see L my $stderr = IO::Handle->new; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, $inc_switch, '-e', "require q[$lib]"); binmode $stderr, ':crlf' if $^O eq 'MSWin32'; my @_warnings = <$stderr>; waitpid($pid, 0); is($?, 0, "$lib loaded ok"); shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/ and not eval { blib->VERSION('1.01') }; if (@_warnings) { warn @_warnings; push @warnings, @_warnings; } } is(scalar(@warnings), 0, 'no warnings found') or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING}; File-Write-Rotate-0.29/t/rotate.t0000644000175000017500000001312412611416723014231 0ustar s1s1#!perl use 5.010; use strict; use warnings; use Test::More 0.98; use File::chdir; use File::Path qw(remove_tree); use File::Slurp::Tiny qw(read_file write_file); use File::Temp qw(tempdir); use File::Write::Rotate; use Taint::Runtime qw(untaint); my $dir = tempdir(CLEANUP=>1); $CWD = $dir; test_rotate( # correctly rename, only keep N histories, doesn't touch other prefixes, # handle compress suffix name => "basic rotate", args => [prefix=>"a", histories=>3], files_before => [qw/a a.1 a.2.gz a.3 b b.1 b.2 b.3 b.4/], before_rotate => sub { write_file("a" , "zero"); write_file("a.1", "one"); write_file("a.2.gz", "two"); write_file("b.1" , "untouched"); }, files_after => [qw/a.1 a.2 a.3.gz b b.1 b.2 b.3 b.4/], after_rotate => sub { is(~~read_file("a.1"), "zero", "a -> a.1"); is(~~read_file("a.2"), "one", "a.2 -> a.2.gz"); is(~~read_file("a.3.gz"), "two", "a.2.gz -> a.3.gz"); is(~~read_file("b.1"), "untouched", "b.1 untouched"); }, ); test_rotate( name => "period, suffix", args => [prefix=>"a", suffix=>".log", histories=>2], files_before => [qw/a.2010-01 a.2011.log a.2012-10.log a.2012-11.log a.2012-12.log/], files_after => [qw/a.2010-01 a.2012-11.log a.2012-12.log.1/], ); test_rotate( name => "period, suffix (complex, no delete)", args => [prefix=>"a", suffix=>".log", histories=>10], files_before => [qw/a.2012-09.log a.2012-10.log a.2012-10.log.1 a.2012-10.log.2 a.2012-11.log a.2012-11.log.1/], files_after => [qw/a.2012-09.log a.2012-10.log a.2012-10.log.1 a.2012-10.log.2 a.2012-11.log.1 a.2012-11.log.2/] ); test_rotate( name => "period, suffix (complex, rotate and delete)", args => [prefix=>"a", suffix=>".log", histories=>3], files_before => [qw/a.2012-09.log a.2012-10.log a.2012-10.log.1 a.2012-10.log.2 a.2012-11.log a.2012-11.log.1/], files_after => [qw/ a.2012-10.log a.2012-11.log.1 a.2012-11.log.2/] ); test_rotate( name => "period, suffix (complex, delete_only)", args => [prefix=>"a", suffix=>".log", histories=>3], rotate_args => [delete_only => 1], files_before => [qw/a.2012-09.log a.2012-10.log a.2012-10.log.1 a.2012-10.log.2 a.2012-11.log a.2012-11.log.1/], files_after => [qw/ a.2012-10.log a.2012-11.log a.2012-11.log.1/] ); { my $executed_hook_before_rotate; my $executed_hook_after_rotate; test_rotate( name => "hook_before_rotate, hook_after_rotate", args => [ prefix=>"a", suffix=>".log", histories=>2, hook_before_rotate => sub { my ($self, $files) = @_; is_deeply($files, [qw/a.2011.log a.2012-10.log a.2012-11.log a.2012-12.log/]) or diag explain $files; $executed_hook_before_rotate = 1; }, hook_after_rotate => sub { my ($self, $renamed, $deleted) = @_; is_deeply($renamed, ["a.2012-12.log.1"], 'renamed argument') or diag explain $renamed; is_deeply($deleted, [qw/ a.2011.log a.2012-10.log /], 'deleted argument') or diag explain $deleted; $executed_hook_after_rotate = 1; }, ], files_before => [qw/a.2010-01 a.2011.log a.2012-10.log a.2012-11.log a.2012-12.log/], files_after => [qw/a.2010-01 a.2012-11.log a.2012-12.log.1/], after_rotate => sub { ok($executed_hook_before_rotate, "hook_before_rotate executed"); ok($executed_hook_after_rotate , "hook_after_rotate executed"); }, ); } { use tainting; test_rotate( # test rename and unlink works under tainting name => "under tainting", args => [prefix=>"a", histories=>3], files_before => [qw/a a.1 a.2 a.3/], before_rotate => sub { write_file($_, "") for (qw/a a.1 a.2 a.3/); }, files_after => [qw/a.1 a.2 a.3/], after_rotate => sub { }, ); } DONE_TESTING: done_testing; if (Test::More->builder->is_passing) { $CWD = "/"; } else { diag "there are failing tests, not deleting test data dir $dir"; } sub test_rotate { my (%args) = @_; subtest $args{name} => sub { my $fwr = File::Write::Rotate->new( dir => $dir, @{$args{args}} ); my $dh; # remove all files first opendir $dh, "."; while (my $e = readdir($dh)) { next if $e eq '.' || $e eq '..'; untaint \$e; remove_tree($e); } write_file($_, "") for @{$args{files_before}}; $args{before_rotate}->($fwr) if $args{before_rotate}; $fwr->_rotate_and_delete($args{rotate_args} ? @{$args{rotate_args}} : ()); undef $fwr; my @files; opendir $dh, "."; while (my $e = readdir($dh)) { next if $e eq '.' || $e eq '..'; push @files, $e; } @files = sort @files; is_deeply(\@files, $args{files_after}, "files_after") or diag explain \@files; $args{after_rotate}->($fwr) if $args{after_rotate}; }; } File-Write-Rotate-0.29/t/todo.t0000644000175000017500000000015412611416723013677 0ustar s1s1#!perl # This is a list of tests that need to be written # TODO: path() print "1..1\n"; print "ok 1\n"; File-Write-Rotate-0.29/t/write.t0000644000175000017500000003655112611416723014076 0ustar s1s1#!perl use 5.010; use strict; use warnings; use File::chdir; use File::Path qw(remove_tree); use File::Slurp::Tiny qw(read_file write_file); use File::Temp qw(tempdir); use File::Write::Rotate; use Monkey::Patch::Action qw(patch_package); use Test::Exception; use Test::Warnings qw(:no_end_test warnings); use Test::More 0.98; $ENV{TZ} = "UTC"; my $dir = tempdir(CLEANUP=>1); $CWD = $dir; test_filehandle_cache( label => "basic", new_params => [dir=>$dir, prefix=>"a"], code => sub { my ($writer) = @_; delete_all_files(); $writer->("[1]"); is(~~read_file("a"), "[1]"); $writer->("[2]", "[3]"); is(~~read_file("a"), "[1][2][3]"); } ); test_filehandle_cache( label => "binmode ':utf8'", new_params => [dir=>$dir, prefix=>"a", binmode => ':utf8'], code => sub { my ($writer) = @_; delete_all_files(); my $text = "\x{263a}"; utf8::upgrade($text); my @warnings = warnings { use warnings; $writer->($text); }; ok(!(grep { $_ =~ /wide character/i } @warnings), "no 'Wide character in ...' warning"); is(~~read_file("a", binmode => ':utf8'), $text, "file contents"); } ); test_filehandle_cache( label => "rotate by size", new_params => [dir=>$dir, prefix=>"a", size=>3], code => sub { my ($writer, $get_fwr) = @_; delete_all_files(); is(($get_fwr->()->_file_path())[1], "", "period"); $writer->("[1]"); is(~~read_file("a"), "[1]"); $writer->("[2]", "[3]"); is(~~read_file("a"), "[2][3]"); is(~~read_file("a.1"), "[1]"); } ); # just testing at some non-negligible size test_filehandle_cache( label => "rotate by size = 20Kb", new_params => [dir=>$dir, prefix=>"a", size=>20*1000], code => sub { my ($writer, $get_fwr) = @_; delete_all_files(); my $msg = "x" x 100; for (1..200) { $writer->($msg) } is( (-s 'a') , 20000, 'first file exists and has 20Kb so far'); is( (-e 'a.1'), undef, 'rotate files does not exists yet' ); note('printing one more message to force rotation bondaries'); $writer->($msg); is( (-s 'a') , 100, 'new file exists and has 100 bytes'); is( (-s 'a.1'), 20000, 'rotate file exists and has 20Kb'); my $orig_size = (-s 'a.1'); test_gzip($get_fwr->(), ['a.1']); # sane value my $comp_size = 0; $comp_size = (-s 'a.1.gz'); if (defined($comp_size)) { cmp_ok($comp_size, '<', $orig_size, 'compressed file size is smaller than before compression'); } else { fail("there is no compressed a.1, cannot compare sizes"); } } ); test_filehandle_cache( label => "rotate by period, daily", new_params => [dir=>$dir, prefix=>"a", period=>"daily"], code => sub { my ($writer, $get_fwr) = @_; delete_all_files(); my $ph; $ph = set_time_to(1356090474); # 2012-12-21 @UTC is(($get_fwr->()->_file_path())[1], "2012-12-21", "period"); $writer->("[1]"); is(~~read_file("a.2012-12-21"), "[1]", 'got expected content in the file (1)'); $writer->("[2]", "[3]"); is(~~read_file("a.2012-12-21"), "[1][2][3]", 'got expected content in the file (2)'); $ph = set_time_to(1356090474 + 86400); # 2012-12-22 @UTC $writer->("[4]"); is(~~read_file("a.2012-12-22"), "[4]", 'got expected content in the file (3)'); #list_files(); test_gzip($get_fwr->(), ['a.2012-12-21']); } ); test_filehandle_cache( label => "rotate by period, monthly", new_params => [dir=>$dir, prefix=>"a", period=>"monthly"], code => sub { my ($writer, $get_fwr) = @_; delete_all_files(); my $ph; $ph = set_time_to(1356090474); # 2012-12-21 @UTC is(($get_fwr->()->_file_path())[1], "2012-12", "period"); $writer->("[1]"); is(~~read_file("a.2012-12"), "[1]"); $writer->("[2]", "[3]"); is(~~read_file("a.2012-12"), "[1][2][3]"); $ph = set_time_to(1356090474 + 31*86400); # 2013-01-21 @UTC $writer->("[4]"); is(~~read_file("a.2013-01"), "[4]"); test_gzip($get_fwr->(), ['a.2012-12']); } ); test_filehandle_cache( label => "rotate by period, yearly", new_params => [dir=>$dir, prefix=>"a", period=>"year"], code => sub { my ($writer, $get_fwr) = @_; delete_all_files(); my $ph; $ph = set_time_to(1356090474); # 2012-12-21 @UTC is(($get_fwr->()->_file_path())[1], "2012", "period"); $writer->("[1]"); is(~~read_file("a.2012"), "[1]"); $writer->("[2]", "[3]"); is(~~read_file("a.2012"), "[1][2][3]"); $ph = set_time_to(1356090474 + 31*86400); # 2013-01-21 @UTC $writer->("[4]"); is(~~read_file("a.2013"), "[4]"); test_gzip($get_fwr->(), ['a.2012']); } ); test_filehandle_cache( label => "rotate by period + size, suffix", new_params => [dir=>$dir, prefix=>"a", suffix=>".log", size=>3, period=>"daily"], code => sub { my ($writer, $get_fwr) = @_; delete_all_files(); my $ph; $ph = set_time_to(1356090474); # 2012-12-21 @UTC is(($get_fwr->()->_file_path())[1], "2012-12-21", "period"); $writer->("[1]"); is(~~read_file("a.2012-12-21.log"), "[1]"); $writer->("[2]", "[3]"); is(~~read_file("a.2012-12-21.log"), "[2][3]"); is(~~read_file("a.2012-12-21.log.1"), "[1]"); $writer->("[4]"); is(~~read_file("a.2012-12-21.log"), "[4]"); is(~~read_file("a.2012-12-21.log.1"), "[2][3]"); is(~~read_file("a.2012-12-21.log.2"), "[1]"); $ph = set_time_to(1356090474 + 86400); # 2012-12-22 @UTC $writer->("[5]"); is(~~read_file("a.2012-12-22.log"), "[5]"); test_gzip($get_fwr->(), ['a.2012-12-21.log', 'a.2012-12-21.log.1', 'a.2012-12-21.log.2']); } ); test_filehandle_cache( label => "two writers, one rotates", new_params => [dir=>$dir, prefix=>"a"], code => sub { my ($writer, $get_fwr1) = @_; delete_all_files(); my $fwr2 = File::Write::Rotate->new(dir=>$dir, prefix=>"a", size=>3); $writer->("[1.1]"); is(~~read_file("a"), "[1.1]"); $fwr2->write("[2.1]"); is(~~read_file("a"), "[2.1]"); is(~~read_file("a.1"), "[1.1]"); $writer->("[1.2]"); is(~~read_file("a"), "[2.1][1.2]"); is(~~read_file("a.1"), "[1.1]"); test_gzip($get_fwr1->(), ['a.1']); } ); # if FWR only rotates after second write(), then there will be cases where the # file won't get rotated at all. subtest "rotate on first write()" => sub { delete_all_files(); write_file("$dir/a", "123"); my $fwr = File::Write::Rotate->new(dir=>$dir, prefix=>"a", size=>3); $fwr->write("[1]"); is(~~read_file("a"), "[1]"); is(~~read_file("a.1"), "123"); test_gzip($fwr, ['a.1']); }; { my @got_messages = (); test_filehandle_cache( label => "hook_before_write basic", new_params => [dir=>$dir, prefix=>"a", hook_before_write => sub { my ($fwr, $msgs, $fh) = @_; push @got_messages, [@$msgs]; ok((-e $fwr->lock_file_path), "lock file exists"); print $fh "hook_before_write"; }], code => sub { my ($writer) = @_; delete_all_files(); @got_messages = (); $writer->("a", "b"); is_deeply(\@got_messages, [["a", "b"]], "hook messages OK"); is_deeply(get_file_contents(), {"a" => "hook_before_writeab"}, "content OK"); } ); } subtest "buffer (success), hook_before_write" => sub { delete_all_files(); my $fwr = File::Write::Rotate->new(dir=>$dir, prefix=>"a", buffer_size=>2); $fwr->{hook_before_write} = sub { die }; lives_ok { $fwr->write("[1]") } "first message to buffer"; lives_ok { $fwr->write("[2]") } "second message to buffer"; ok((! -e $fwr->lock_file_path), "should be unlocked"); undef $fwr->{hook_before_write}; $fwr->write("[3]"); is(~~read_file("a"), "[1][2][3]", "buffered messages gets logged"); $fwr->write("[4]"); is(~~read_file("a"), "[1][2][3][4]", "buffered is emptied"); ok((! -e $fwr->lock_file_path), "should be unlocked"); }; subtest "buffer (failed, full), buffer_size attribute" => sub { delete_all_files(); my $fwr = File::Write::Rotate->new(dir=>$dir, prefix=>"a"); $fwr->buffer_size(2); is($fwr->buffer_size, 2, 'buffer_size()'); local $fwr->{hook_before_write} = sub { die }; lives_ok { $fwr->write("[1]") } "first message to buffer"; ok((! -e $fwr->lock_file_path), "should be unlocked"); lives_ok { $fwr->write("[2]") } "second message to buffer"; ok((! -e $fwr->lock_file_path), "should be unlocked"); throws_ok { $fwr->write("[3]") } qr/\Q[1][2][3]\E/, "buffer is full"; ok((! -e $fwr->lock_file_path), "should be unlocked"); }; subtest "hook_after_create" => sub { delete_all_files(); my $fwr = File::Write::Rotate->new( dir=>$dir, prefix=>"a", hook_after_create => sub { my ($self) = @_; my $fh = $self->handle; print $fh "header\n"; }, ); $fwr->write("[1]"); is(~~read_file("a"), "header\n[1]"); }; test_filehandle_cache( label => "rotate by period, daily + histories", new_params => [dir=>$dir, prefix=>"a", period=>"daily", histories=>2], code => sub { my ($writer) = @_; delete_all_files(); my $ph; my $time_base = 1356090474; # 2012-12-21 @UTC my $DAY = 3600 * 24; $ph = set_time_to($time_base); $writer->("[1]"); is_deeply(get_file_contents(), {"a.2012-12-21" => "[1]"}, "current file only"); $ph = set_time_to($time_base + 1 * $DAY); $writer->("[2]"); is_deeply(get_file_contents(), {"a.2012-12-21" => "[1]", "a.2012-12-22" => "[2]"}, "1 history"); $ph = set_time_to($time_base + 2 * $DAY); $writer->("[3]"); is_deeply(get_file_contents(), {"a.2012-12-21" => "[1]", "a.2012-12-22" => "[2]", "a.2012-12-23" => "[3]"}, "2 histories"); $ph = set_time_to($time_base + 3 * $DAY); $writer->("[4]"); is_deeply(get_file_contents(), {"a.2012-12-22" => "[2]", "a.2012-12-23" => "[3]", "a.2012-12-24" => "[4]"}, "2 histories (deleted)"); } ); test_filehandle_cache( label => "rotate by size + histories", new_params => [dir=>$dir, prefix=>"a", size=>3, histories=>2], code => sub { my ($writer) = @_; delete_all_files(); $writer->("[1]"); is_deeply(get_file_contents(), {"a" => "[1]"}, "current file only"); $writer->("[2]", "[3]"); is_deeply(get_file_contents(), {"a" => "[2][3]", "a.1" => "[1]"}, "1 history (rotated)"); $writer->("[4][5]"); is_deeply(get_file_contents(), {"a" => "[4][5]", "a.1" => "[2][3]", "a.2" => "[1]"}, "2 histories (rotated)"); $writer->("[6]"); is_deeply(get_file_contents(), {"a" => "[6]", "a.1" => "[4][5]", "a.2" => "[2][3]"}, "2 histories (rotated and deleted)"); } ); test_filehandle_cache( label => "rotate by size + period + histories", new_params => [dir=>$dir, prefix=>"a", period=>"daily", size=>3, histories=>3], code => sub { my ($writer) = @_; delete_all_files(); my $ph; my $time_base = 1356090474; # 2012-12-21 @UTC my $DAY = 3600 * 24; $ph = set_time_to($time_base); $writer->("[1]"); is_deeply(get_file_contents(), {"a.2012-12-21" => "[1]"}); $writer->("[2]"); is_deeply(get_file_contents(), {"a.2012-12-21.1" => "[1]", "a.2012-12-21" => "[2]"}); $ph = set_time_to($time_base + 1 * $DAY); $writer->("[3]"); is_deeply(get_file_contents(), {"a.2012-12-21.1" => "[1]", "a.2012-12-21" => "[2]", "a.2012-12-22" => "[3]"}); $writer->("[4]"); is_deeply(get_file_contents(), {"a.2012-12-21.1" => "[1]", "a.2012-12-21" => "[2]", "a.2012-12-22.1" => "[3]", "a.2012-12-22" => "[4]"}, "rotate 2012-12-22 but NOT 2012-12-21"); $writer->("[5]"); is_deeply(get_file_contents(), {"a.2012-12-21" => "[2]", "a.2012-12-22.2" => "[3]", "a.2012-12-22.1" => "[4]", "a.2012-12-22" => "[5]"}, "delete [1] as a result of rotating at 2012-12-22"); $ph = set_time_to($time_base + 2 * $DAY); $writer->("[6]"); is_deeply(get_file_contents(), {"a.2012-12-22.2" => "[3]", "a.2012-12-22.1" => "[4]", "a.2012-12-22" => "[5]", "a.2012-12-23" => "[6]"}, "delete [2] as a result of entering the new period"); $writer->("[7"); is_deeply(get_file_contents(), {"a.2012-12-22.1" => "[4]", "a.2012-12-22" => "[5]", "a.2012-12-23.1" => "[6]", "a.2012-12-23" => "[7"}); $writer->("]"); is_deeply(get_file_contents(), {"a.2012-12-22.1" => "[4]", "a.2012-12-22" => "[5]", "a.2012-12-23.1" => "[6]", "a.2012-12-23" => "[7]"}, "not rotating because it's within the size limite"); } ); DONE_TESTING: done_testing; if (Test::More->builder->is_passing) { $CWD = "/"; } else { diag "there are failing tests, not deleting test data dir $dir"; } sub delete_all_files { # remove all files first opendir my($dh), "."; while (my $e = readdir($dh)) { next if $e eq '.' || $e eq '..'; remove_tree($e); } } sub get_files { opendir my $dh, "."; return [grep {$_ ne '.' && $_ ne '..'} readdir $dh]; } sub list_files { diag explain get_files(); } sub get_file_contents { my $files = get_files(); return { map { $_ => ~~read_file($_) } @$files }; } our $Time; sub _time() { $Time } sub set_time_to { $Time = shift; my $ph = patch_package("File::Write::Rotate", 'time', 'replace', \&_time); return $ph; } sub test_gzip { my $fwr = shift; my $files_ref = shift; my @sizes; for my $filename(@{$files_ref}) { push(@sizes, (-s $filename)); } my $ret = $fwr->compress; ok($ret, 'compress method returns true') or return; my $counter = 0; for my $filename(@{$files_ref}) { my $orig_size = $sizes[$counter]; $counter++; my $new_file = $filename . '.gz'; ok( (-s $new_file), "rotated file $filename was compressed to $new_file"); #1 ok(!(-e $filename), "original $filename is deleted"); #2 } } sub test_filehandle_cache { my (%args) = @_; my $label_base = $args{label}; my $new_params_ref = $args{new_params}; my $code = $args{code}; subtest "Filehandle cached: $label_base", sub { my $fwr = File::Write::Rotate->new(@$new_params_ref); my $get_fwr = sub { $fwr }; my $writer = sub { $fwr->write(@_); ok((! -e $fwr->lock_file_path), "should be unlocked"); }; $code->($writer, $get_fwr); }; subtest "Filehandle not cached: $label_base", sub { my $get_fwr = sub { File::Write::Rotate->new(@$new_params_ref) }; my $writer = sub { my $fwr = $get_fwr->(); $fwr->write(@_); ok((! -e $fwr->lock_file_path), "should be unlocked"); }; $code->($writer, $get_fwr); }; } File-Write-Rotate-0.29/t/release-pod-coverage.t0000644000175000017500000000057212611416723016727 0ustar s1s1#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } # This file was automatically generated by Dist::Zilla::Plugin::PodCoverageTests. use Test::Pod::Coverage 1.08; use Pod::Coverage::TrustPod; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' }); File-Write-Rotate-0.29/t/release-pod-syntax.t0000644000175000017500000000045612611416723016463 0ustar s1s1#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use Test::More; use Test::Pod 1.41; all_pod_files_ok(); File-Write-Rotate-0.29/t/lock.t0000644000175000017500000000537312611416723013672 0ustar s1s1#!perl use 5.010; use strict; use warnings; use File::chdir; use File::Temp qw(tempdir); use File::Write::Rotate; use Test::Exception; use Test::More 0.98; use Test::Warnings qw(:no_end_test warnings); my $dir = tempdir(CLEANUP=>1); $CWD = $dir; test_locking( label => "none", prefix => "a", new_params => { lock_mode => "none", }, locked_write => 0, locked_creation => 0, ); test_locking( label => "write", prefix => "b", new_params => { lock_mode => "write", }, locked_write => 1, locked_creation => 0, ); test_locking( label => "exclusive", prefix => "c", new_params => { lock_mode => "exclusive", }, locked_write => 1, locked_creation => 1, ); sub check_lock { my ($lockfile, $label, $expected) = @_; ok((-e $lockfile), "lock file exists: $label") if $expected; ok((! -e $lockfile), "lock file doesn't exist: $label") if ! $expected; } sub test_locking { my (%args) = @_; my $label_base = $args{label}; my $prefix = $args{prefix}; my %new_params = %{$args{new_params}}; my %seen; subtest "locking: $label_base" => sub { my $lockfile; { my $fwr = File::Write::Rotate->new( %new_params, dir => $dir, prefix => $prefix, size => 1, hook_after_create => sub { $seen{hook_after_create} = 1; check_lock($lockfile, "hook_after_create", $args{locked_write}); }, hook_before_write => sub { $seen{hook_before_write} = 1; check_lock($lockfile, "hook_before_write", $args{locked_write}); }, hook_before_rotate => sub { $seen{hook_before_rotate} = 1; check_lock($lockfile, "hook_before_rotate", $args{locked_write}); }, hook_after_rotate => sub { $seen{hook_after_rotate} = 1; check_lock($lockfile, "hook_after_rotate", $args{locked_write}); }, ); $lockfile = $fwr->lock_file_path; check_lock($lockfile, "created", $args{locked_creation}); $fwr->write("[1]\n"); check_lock($lockfile, "after 1st write", $args{locked_creation}); $fwr->write("[2]\n"); check_lock($lockfile, "after 2nd write", $args{locked_creation}); is(scalar keys %seen, 4, "Expected 4 hooks to run"); } check_lock($lockfile, "out of scope", 0); }; } DONE_TESTING: done_testing; if (Test::More->builder->is_passing) { $CWD = "/"; } else { diag "there are failing tests, not deleting test data dir $dir"; } File-Write-Rotate-0.29/weaver.ini0000644000175000017500000000002512611416723014271 0ustar s1s1[@Author::PERLANCAR] File-Write-Rotate-0.29/MANIFEST0000644000175000017500000000044312611416723013434 0ustar s1s1# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.037. Changes LICENSE MANIFEST META.json META.yml Makefile.PL README dist.ini lib/File/Write/Rotate.pm t/00-compile.t t/lock.t t/release-pod-coverage.t t/release-pod-syntax.t t/rotate.t t/todo.t t/write.t weaver.ini File-Write-Rotate-0.29/META.json0000644000175000017500000004222712611416723013732 0ustar s1s1{ "abstract" : "Write to files that archive/rotate themselves", "author" : [ "perlancar " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 5.037, CPAN::Meta::Converter version 2.150005", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "File-Write-Rotate", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "develop" : { "requires" : { "Pod::Coverage::TrustPod" : "0", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08" } }, "runtime" : { "requires" : { "File::Flock::Retry" : "0", "Proc::PID::File" : "0", "perl" : "5.010001" } }, "test" : { "requires" : { "File::Slurp::Tiny" : "0", "File::Spec" : "0", "File::chdir" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "Monkey::Patch::Action" : "0", "Taint::Runtime" : "0", "Test::Exception" : "0.31", "Test::More" : "0.98", "Test::Warnings" : "0.014", "tainting" : "0.01" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://rt.cpan.org/Public/Dist/Display.html?Name=File-Write-Rotate" }, "homepage" : "https://metacpan.org/release/File-Write-Rotate", "repository" : { "type" : "git", "url" : "git://github.com/perlancar/perl-File-Write-Rotate.git", "web" : "https://github.com/perlancar/perl-File-Write-Rotate" } }, "version" : "0.29", "x_Dist_Zilla" : { "perl" : { "version" : "5.022000" }, "plugins" : [ { "class" : "Dist::Zilla::Plugin::GatherDir", "config" : { "Dist::Zilla::Plugin::GatherDir" : { "exclude_filename" : [], "exclude_match" : [], "follow_symlinks" : "0", "include_dotfiles" : "0", "prefix" : "", "prune_directory" : [], "root" : "." } }, "name" : "@Author::PERLANCAR/@Filter/GatherDir", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::PruneCruft", "name" : "@Author::PERLANCAR/@Filter/PruneCruft", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::ManifestSkip", "name" : "@Author::PERLANCAR/@Filter/ManifestSkip", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", "name" : "@Author::PERLANCAR/@Filter/MetaYAML", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::License", "name" : "@Author::PERLANCAR/@Filter/License", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::PodCoverageTests", "name" : "@Author::PERLANCAR/@Filter/PodCoverageTests", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::PodSyntaxTests", "name" : "@Author::PERLANCAR/@Filter/PodSyntaxTests", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::ExtraTests", "name" : "@Author::PERLANCAR/@Filter/ExtraTests", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::ExecDir", "name" : "@Author::PERLANCAR/@Filter/ExecDir", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::ShareDir", "name" : "@Author::PERLANCAR/@Filter/ShareDir", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::MakeMaker", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 1 } }, "name" : "@Author::PERLANCAR/@Filter/MakeMaker", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::Manifest", "name" : "@Author::PERLANCAR/@Filter/Manifest", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::ConfirmRelease", "name" : "@Author::PERLANCAR/@Filter/ConfirmRelease", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::UploadToCPAN", "name" : "@Author::PERLANCAR/@Filter/UploadToCPAN", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::Rinci::AbstractFromMeta", "name" : "@Author::PERLANCAR/Rinci::AbstractFromMeta", "version" : "0.08" }, { "class" : "Dist::Zilla::Plugin::PodnameFromFilename", "name" : "@Author::PERLANCAR/PodnameFromFilename", "version" : "0.01" }, { "class" : "Dist::Zilla::Plugin::PERLANCAR::CheckDepDists", "name" : "@Author::PERLANCAR/PERLANCAR::CheckDepDists", "version" : "0.04" }, { "class" : "Dist::Zilla::Plugin::PERLANCAR::EnsurePrereqToSpec", "name" : "@Author::PERLANCAR/PERLANCAR::EnsurePrereqToSpec", "version" : "0.01" }, { "class" : "Dist::Zilla::Plugin::PERLANCAR::MetaResources", "name" : "@Author::PERLANCAR/PERLANCAR::MetaResources", "version" : "0.03" }, { "class" : "Dist::Zilla::Plugin::CheckChangeLog", "name" : "@Author::PERLANCAR/CheckChangeLog", "version" : "0.02" }, { "class" : "Dist::Zilla::Plugin::CheckMetaResources", "name" : "@Author::PERLANCAR/CheckMetaResources", "version" : "0.001" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", "name" : "@Author::PERLANCAR/MetaJSON", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", "name" : "@Author::PERLANCAR/MetaConfig", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::GenShellCompletion", "name" : "@Author::PERLANCAR/GenShellCompletion", "version" : "0.09" }, { "class" : "Dist::Zilla::Plugin::Authority", "name" : "@Author::PERLANCAR/Authority", "version" : "1.009" }, { "class" : "Dist::Zilla::Plugin::OurDate", "name" : "@Author::PERLANCAR/OurDate", "version" : "0.03" }, { "class" : "Dist::Zilla::Plugin::OurDist", "name" : "@Author::PERLANCAR/OurDist", "version" : "0.02" }, { "class" : "Dist::Zilla::Plugin::PERLANCAR::OurPkgVersion", "name" : "@Author::PERLANCAR/PERLANCAR::OurPkgVersion", "version" : "0.04" }, { "class" : "Dist::Zilla::Plugin::PodWeaver", "config" : { "Dist::Zilla::Plugin::PodWeaver" : { "finder" : [ ":InstallModules", ":ExecFiles" ], "plugins" : [ { "class" : "Pod::Weaver::Plugin::EnsurePod5", "name" : "@CorePrep/EnsurePod5", "version" : "4.012" }, { "class" : "Pod::Weaver::Plugin::H1Nester", "name" : "@CorePrep/H1Nester", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Name", "name" : "@Author::PERLANCAR/Name", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Version", "name" : "@Author::PERLANCAR/Version", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@Author::PERLANCAR/prelude", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "SYNOPSIS", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "DESCRIPTION", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "OVERVIEW", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "ATTRIBUTES", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "METHODS", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "FUNCTIONS", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Leftovers", "name" : "@Author::PERLANCAR/Leftovers", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@Author::PERLANCAR/postlude", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Completion::GetoptLongComplete", "name" : "@Author::PERLANCAR/Completion::GetoptLongComplete", "version" : "0.07" }, { "class" : "Pod::Weaver::Section::Completion::GetoptLongSubcommand", "name" : "@Author::PERLANCAR/Completion::GetoptLongSubcommand", "version" : "0.03" }, { "class" : "Pod::Weaver::Section::Completion::PerinciCmdLine", "name" : "@Author::PERLANCAR/Completion::PerinciCmdLine", "version" : "0.13" }, { "class" : "Pod::Weaver::Section::Homepage::DefaultCPAN", "name" : "@Author::PERLANCAR/Homepage::DefaultCPAN", "version" : "0.05" }, { "class" : "Pod::Weaver::Section::Source::DefaultGitHub", "name" : "@Author::PERLANCAR/Source::DefaultGitHub", "version" : "0.07" }, { "class" : "Pod::Weaver::Section::Bugs::DefaultRT", "name" : "@Author::PERLANCAR/Bugs::DefaultRT", "version" : "0.05" }, { "class" : "Pod::Weaver::Section::Authors", "name" : "@Author::PERLANCAR/Authors", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Legal", "name" : "@Author::PERLANCAR/Legal", "version" : "4.012" }, { "class" : "Pod::Weaver::Plugin::Rinci", "name" : "@Author::PERLANCAR/Rinci", "version" : "0.47" }, { "class" : "Pod::Weaver::Plugin::AppendPrepend", "name" : "@Author::PERLANCAR/AppendPrepend", "version" : "0.01" }, { "class" : "Pod::Weaver::Plugin::EnsureUniqueSections", "name" : "@Author::PERLANCAR/EnsureUniqueSections", "version" : "0.121550" }, { "class" : "Pod::Weaver::Plugin::SingleEncoding", "name" : "@Author::PERLANCAR/SingleEncoding", "version" : "4.012" } ] } }, "name" : "@Author::PERLANCAR/PodWeaver", "version" : "4.006" }, { "class" : "Dist::Zilla::Plugin::PruneFiles", "name" : "@Author::PERLANCAR/PruneFiles", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::ReadmeFromPod", "name" : "@Author::PERLANCAR/ReadmeFromPod", "version" : "0.32" }, { "class" : "Dist::Zilla::Plugin::Rinci::AddPrereqs", "name" : "@Author::PERLANCAR/Rinci::AddPrereqs", "version" : "0.06" }, { "class" : "Dist::Zilla::Plugin::Rinci::Validate", "name" : "@Author::PERLANCAR/Rinci::Validate", "version" : "0.20" }, { "class" : "Dist::Zilla::Plugin::SetScriptShebang", "name" : "@Author::PERLANCAR/SetScriptShebang", "version" : "0.01" }, { "class" : "Dist::Zilla::Plugin::Test::Compile", "config" : { "Dist::Zilla::Plugin::Test::Compile" : { "bail_out_on_fail" : "0", "fail_on_warning" : "author", "fake_home" : "0", "filename" : "t/00-compile.t", "module_finder" : [ ":InstallModules" ], "needs_display" : "0", "phase" : "test", "script_finder" : [ ":ExecFiles" ], "skips" : [] } }, "name" : "@Author::PERLANCAR/Test::Compile", "version" : "2.053" }, { "class" : "Dist::Zilla::Plugin::Test::Rinci", "name" : "@Author::PERLANCAR/Test::Rinci", "version" : "0.03" }, { "class" : "Dist::Zilla::Plugin::EnsureSQLSchemaVersionedTest", "name" : "@Author::PERLANCAR/EnsureSQLSchemaVersionedTest", "version" : "0.01" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "test", "type" : "requires" } }, "name" : "TestRequires", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "runtime", "type" : "requires" } }, "name" : "Prereqs", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":IncModules", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":MainModule", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":AllFiles", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":NoFiles", "version" : "5.037" } ], "zilla" : { "class" : "Dist::Zilla::Dist::Builder", "config" : { "is_trial" : "0" }, "version" : "5.037" } }, "x_authority" : "cpan:PERLANCAR" } File-Write-Rotate-0.29/META.yml0000644000175000017500000002657012611416723013565 0ustar s1s1--- abstract: 'Write to files that archive/rotate themselves' author: - 'perlancar ' build_requires: File::Slurp::Tiny: '0' File::Spec: '0' File::chdir: '0' IO::Handle: '0' IPC::Open3: '0' Monkey::Patch::Action: '0' Taint::Runtime: '0' Test::Exception: '0.31' Test::More: '0.98' Test::Warnings: '0.014' tainting: '0.01' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 0 generated_by: 'Dist::Zilla version 5.037, CPAN::Meta::Converter version 2.150005' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: File-Write-Rotate requires: File::Flock::Retry: '0' Proc::PID::File: '0' perl: '5.010001' resources: bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=File-Write-Rotate homepage: https://metacpan.org/release/File-Write-Rotate repository: git://github.com/perlancar/perl-File-Write-Rotate.git version: '0.29' x_Dist_Zilla: perl: version: '5.022000' plugins: - class: Dist::Zilla::Plugin::GatherDir config: Dist::Zilla::Plugin::GatherDir: exclude_filename: [] exclude_match: [] follow_symlinks: '0' include_dotfiles: '0' prefix: '' prune_directory: [] root: . name: '@Author::PERLANCAR/@Filter/GatherDir' version: '5.037' - class: Dist::Zilla::Plugin::PruneCruft name: '@Author::PERLANCAR/@Filter/PruneCruft' version: '5.037' - class: Dist::Zilla::Plugin::ManifestSkip name: '@Author::PERLANCAR/@Filter/ManifestSkip' version: '5.037' - class: Dist::Zilla::Plugin::MetaYAML name: '@Author::PERLANCAR/@Filter/MetaYAML' version: '5.037' - class: Dist::Zilla::Plugin::License name: '@Author::PERLANCAR/@Filter/License' version: '5.037' - class: Dist::Zilla::Plugin::PodCoverageTests name: '@Author::PERLANCAR/@Filter/PodCoverageTests' version: '5.037' - class: Dist::Zilla::Plugin::PodSyntaxTests name: '@Author::PERLANCAR/@Filter/PodSyntaxTests' version: '5.037' - class: Dist::Zilla::Plugin::ExtraTests name: '@Author::PERLANCAR/@Filter/ExtraTests' version: '5.037' - class: Dist::Zilla::Plugin::ExecDir name: '@Author::PERLANCAR/@Filter/ExecDir' version: '5.037' - class: Dist::Zilla::Plugin::ShareDir name: '@Author::PERLANCAR/@Filter/ShareDir' version: '5.037' - class: Dist::Zilla::Plugin::MakeMaker config: Dist::Zilla::Role::TestRunner: default_jobs: 1 name: '@Author::PERLANCAR/@Filter/MakeMaker' version: '5.037' - class: Dist::Zilla::Plugin::Manifest name: '@Author::PERLANCAR/@Filter/Manifest' version: '5.037' - class: Dist::Zilla::Plugin::ConfirmRelease name: '@Author::PERLANCAR/@Filter/ConfirmRelease' version: '5.037' - class: Dist::Zilla::Plugin::UploadToCPAN name: '@Author::PERLANCAR/@Filter/UploadToCPAN' version: '5.037' - class: Dist::Zilla::Plugin::Rinci::AbstractFromMeta name: '@Author::PERLANCAR/Rinci::AbstractFromMeta' version: '0.08' - class: Dist::Zilla::Plugin::PodnameFromFilename name: '@Author::PERLANCAR/PodnameFromFilename' version: '0.01' - class: Dist::Zilla::Plugin::PERLANCAR::CheckDepDists name: '@Author::PERLANCAR/PERLANCAR::CheckDepDists' version: '0.04' - class: Dist::Zilla::Plugin::PERLANCAR::EnsurePrereqToSpec name: '@Author::PERLANCAR/PERLANCAR::EnsurePrereqToSpec' version: '0.01' - class: Dist::Zilla::Plugin::PERLANCAR::MetaResources name: '@Author::PERLANCAR/PERLANCAR::MetaResources' version: '0.03' - class: Dist::Zilla::Plugin::CheckChangeLog name: '@Author::PERLANCAR/CheckChangeLog' version: '0.02' - class: Dist::Zilla::Plugin::CheckMetaResources name: '@Author::PERLANCAR/CheckMetaResources' version: '0.001' - class: Dist::Zilla::Plugin::MetaJSON name: '@Author::PERLANCAR/MetaJSON' version: '5.037' - class: Dist::Zilla::Plugin::MetaConfig name: '@Author::PERLANCAR/MetaConfig' version: '5.037' - class: Dist::Zilla::Plugin::GenShellCompletion name: '@Author::PERLANCAR/GenShellCompletion' version: '0.09' - class: Dist::Zilla::Plugin::Authority name: '@Author::PERLANCAR/Authority' version: '1.009' - class: Dist::Zilla::Plugin::OurDate name: '@Author::PERLANCAR/OurDate' version: '0.03' - class: Dist::Zilla::Plugin::OurDist name: '@Author::PERLANCAR/OurDist' version: '0.02' - class: Dist::Zilla::Plugin::PERLANCAR::OurPkgVersion name: '@Author::PERLANCAR/PERLANCAR::OurPkgVersion' version: '0.04' - class: Dist::Zilla::Plugin::PodWeaver config: Dist::Zilla::Plugin::PodWeaver: finder: - ':InstallModules' - ':ExecFiles' plugins: - class: Pod::Weaver::Plugin::EnsurePod5 name: '@CorePrep/EnsurePod5' version: '4.012' - class: Pod::Weaver::Plugin::H1Nester name: '@CorePrep/H1Nester' version: '4.012' - class: Pod::Weaver::Section::Name name: '@Author::PERLANCAR/Name' version: '4.012' - class: Pod::Weaver::Section::Version name: '@Author::PERLANCAR/Version' version: '4.012' - class: Pod::Weaver::Section::Region name: '@Author::PERLANCAR/prelude' version: '4.012' - class: Pod::Weaver::Section::Generic name: SYNOPSIS version: '4.012' - class: Pod::Weaver::Section::Generic name: DESCRIPTION version: '4.012' - class: Pod::Weaver::Section::Generic name: OVERVIEW version: '4.012' - class: Pod::Weaver::Section::Collect name: ATTRIBUTES version: '4.012' - class: Pod::Weaver::Section::Collect name: METHODS version: '4.012' - class: Pod::Weaver::Section::Collect name: FUNCTIONS version: '4.012' - class: Pod::Weaver::Section::Leftovers name: '@Author::PERLANCAR/Leftovers' version: '4.012' - class: Pod::Weaver::Section::Region name: '@Author::PERLANCAR/postlude' version: '4.012' - class: Pod::Weaver::Section::Completion::GetoptLongComplete name: '@Author::PERLANCAR/Completion::GetoptLongComplete' version: '0.07' - class: Pod::Weaver::Section::Completion::GetoptLongSubcommand name: '@Author::PERLANCAR/Completion::GetoptLongSubcommand' version: '0.03' - class: Pod::Weaver::Section::Completion::PerinciCmdLine name: '@Author::PERLANCAR/Completion::PerinciCmdLine' version: '0.13' - class: Pod::Weaver::Section::Homepage::DefaultCPAN name: '@Author::PERLANCAR/Homepage::DefaultCPAN' version: '0.05' - class: Pod::Weaver::Section::Source::DefaultGitHub name: '@Author::PERLANCAR/Source::DefaultGitHub' version: '0.07' - class: Pod::Weaver::Section::Bugs::DefaultRT name: '@Author::PERLANCAR/Bugs::DefaultRT' version: '0.05' - class: Pod::Weaver::Section::Authors name: '@Author::PERLANCAR/Authors' version: '4.012' - class: Pod::Weaver::Section::Legal name: '@Author::PERLANCAR/Legal' version: '4.012' - class: Pod::Weaver::Plugin::Rinci name: '@Author::PERLANCAR/Rinci' version: '0.47' - class: Pod::Weaver::Plugin::AppendPrepend name: '@Author::PERLANCAR/AppendPrepend' version: '0.01' - class: Pod::Weaver::Plugin::EnsureUniqueSections name: '@Author::PERLANCAR/EnsureUniqueSections' version: '0.121550' - class: Pod::Weaver::Plugin::SingleEncoding name: '@Author::PERLANCAR/SingleEncoding' version: '4.012' name: '@Author::PERLANCAR/PodWeaver' version: '4.006' - class: Dist::Zilla::Plugin::PruneFiles name: '@Author::PERLANCAR/PruneFiles' version: '5.037' - class: Dist::Zilla::Plugin::ReadmeFromPod name: '@Author::PERLANCAR/ReadmeFromPod' version: '0.32' - class: Dist::Zilla::Plugin::Rinci::AddPrereqs name: '@Author::PERLANCAR/Rinci::AddPrereqs' version: '0.06' - class: Dist::Zilla::Plugin::Rinci::Validate name: '@Author::PERLANCAR/Rinci::Validate' version: '0.20' - class: Dist::Zilla::Plugin::SetScriptShebang name: '@Author::PERLANCAR/SetScriptShebang' version: '0.01' - class: Dist::Zilla::Plugin::Test::Compile config: Dist::Zilla::Plugin::Test::Compile: bail_out_on_fail: '0' fail_on_warning: author fake_home: '0' filename: t/00-compile.t module_finder: - ':InstallModules' needs_display: '0' phase: test script_finder: - ':ExecFiles' skips: [] name: '@Author::PERLANCAR/Test::Compile' version: '2.053' - class: Dist::Zilla::Plugin::Test::Rinci name: '@Author::PERLANCAR/Test::Rinci' version: '0.03' - class: Dist::Zilla::Plugin::EnsureSQLSchemaVersionedTest name: '@Author::PERLANCAR/EnsureSQLSchemaVersionedTest' version: '0.01' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: test type: requires name: TestRequires version: '5.037' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: runtime type: requires name: Prereqs version: '5.037' - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: '5.037' - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' version: '5.037' - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: '5.037' - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: '5.037' - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: '5.037' - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' version: '5.037' - class: Dist::Zilla::Plugin::FinderCode name: ':AllFiles' version: '5.037' - class: Dist::Zilla::Plugin::FinderCode name: ':NoFiles' version: '5.037' zilla: class: Dist::Zilla::Dist::Builder config: is_trial: '0' version: '5.037' x_authority: cpan:PERLANCAR