PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Logging » Log » Bug #9032

Optionally limit the number of lines in a log file

Details

Request #9032Optionally limit the number of lines in a log file
Submitted2006-10-14 18:56 UTC
Fromburnhamt at carleton dot edu
Assignedjon
StatusClosed
PackageLog
PHP VersionIrrelevant
OSAny
Roadmaps(Not assigned)

Comments

[2006-10-14 18:56 UTC] burnhamt at carleton dot edu

Description:
------------
I've wrriten a patch that adds a lineLimit feature to the file
handler of the Log package, so that logs can be kept down to a
certain number of lines automatically.

http://phpfi.com/163665

Test script:
---------------
<?php

require_once 'Log.php';

$conf = array('mode' => 0600, 'timeFormat' => '%X %x',
'lineLimit' => 20, 'append' => true);
$logger = &Log::singleton('file', 'out.txt', 'ident', $conf);
for ($i = 0; $i < 50; $i++) {
$logger->log("Log entry $i");
}

?>

Expected result:
----------------
50 log entries will be written, but the log file will, in the
end, contain only the last 20 of those entries (31-50).

Actual result:
--------------
The same! This patch has been tested and maintains backward
compatibility. I don't expect any problems unless lineLimit
is set to something that doesn't make sense (that is,
something other than a positive integer).