Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.6 / 3....
  • Linux Kernel 3.0.82 LTS...
  • KDE Software Compilatio...
  • PulseAudio 4.0
  • Wireshark 1.10.0
  • NetworkManager 0.9.8.2
  • LibreOffice 3.6.6 / 4.0...
  • SystemRescueCd 3.7.0
  • Linux Kernel 3.10 RC6
  • Ubuntu Tweak 0.8.5
  • Home > Linux > Programming > Perl Modules

    Logfile::Rotate 1.04

    Download button

    No screenshots available
    Downloads: 139  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Paul Gampe | More programs
    Perl Artistic License / FREE
    February 23rd, 2011, 09:22 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    Logfile::Rotate description

    Perl module to rotate logfiles

    The use of the Logfile::Rotate module closely relates to the processing logfiles.

    new

     new accepts the following arguments, File, Count, Gzip, Pre, Post, Flock and Dir with only File being mandatory. new will open and lock the file, so you may co-ordinate the processing of the file with rotating it. The file is closed and unlocked when the object is destroyed, so you can do this explicitly by undef'ing the object.

     The Pre/Post arguments allow you to pass function references to this method, which you may use as a callback for any processing you want before or after the rotation. For example, you may notify the process writing to the file that it has been rotated.

     The Pre function is passed the current filename to be rotated as an argument and the Post function is passed the current filename that was rotated and that file's new filename including any extension added by compression previously.

     Both the Pre and Post function references you provide are executed within an eval statement inside the rotate method. If the eval returns an error then the rotate method will croak at that point.

     The Signal argument is deprecated by the Post argument.

     The Flock argument allows you to specify whether the perl function flock is used to lock the file during the rotation operation. Apparently flock causes problems on some platforms and this option has been added to allow you to control the programs behaviour. By default the file will be locked using flock.

     The Persist argument allows you to control whether the program will try and set the current log file ownership and permissions on any new files that may be created by the rotation. In some circumstances the program doing the file rotation may not have sufficient permission to chown on the file. By default the program will try and preserve ownership and permissions.

    rotate()

     This method will copy the file passed in new to a file of the same name, with a numeric extension and truncate the original file to zero length. The numeric extension will range from 1 up to the value specified by Count, or 7 if none is defined, with 1 being the most recent file. When Count is reached, the older file is discarded in a FIFO (first in, first out) fashion. If the argument Dir was given, all old files will be placed in the specified directory.

     The Post function is the last step executed by the rotate method so the return code of rotate will be the return code of the function you proved, or 1 by default.

     The copy function is implemented by using the File::Copy package, but I have had a few people suggest that they would prefer File::Move. I'm still not decided on this as you would loose data if the move should fail.

    SYNOPSIS

     use Logfile::Rotate;
     my $log = new Logfile::Rotate( File => '/var/adm/syslog/syslog.log',
     Count => 7,
     Gzip => 'lib',
     Post => sub{
     open(IN, "/var/run/syslog.pid");
     kill("HUP", chomp(< IN >)); }
     Dir => '/var/log/old',
     Flock => 'yes',
     Persist => 'yes',
     );

     # process log file

     $log->rotate();

     or
     
     my $log = new Logfile::Rotate( File => '/var/adm/syslog',
     Gzip => '/usr/local/bin/gzip');
     
     # process log file

     $log->rotate();
     undef $log;



    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    rotate logfiles | Perl module | Perl | logfiles | rotator

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM