RollFileHandle.pm |
use RollFileHandle;
my $dl=new RollFileHandle(">> /tmp/$0.stdout.%m%d");
$dl->trap_stdxxx(); # install as default for stdout
while($event_loop){
$dl->roll_logfile(); # re-open log file when date rolls.
print("1","2","3\n"); # use vanilla print syntax.
This package is intended to give the caller the ability to create a "rolling" log file of its output, so that a single output log doesn't grow unrestricted.
If the process is dropped and restarted, the log file will be appended onto instead of truncated.
roll_logfile
Open the correct logfile for the current time. if there is no work to do, exit without making any changes.
midnite_time
Calculate the time for midnight tonight, when we'll need to roll the log (again)
NONE
UNK
NONE
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 2 of the License, 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.
RollFileHandle.pm |