Skip to content

Commit

Permalink
fixes FileLog doesn't delete on rotation if count(files) is greater '…
Browse files Browse the repository at this point in the history
…rotate'
  • Loading branch information
Schlaefer committed Oct 6, 2013
1 parent 355e2ef commit 83d340a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Cake/Log/Engine/FileLog.php
Expand Up @@ -206,7 +206,7 @@ protected function _rotateFile($filename) {

if ($this->_config['rotate']) {
$files = glob($filepath . '.*');
if (count($files) === $this->_config['rotate']) {
while (count($files) >= $this->_config['rotate']) {
unlink(array_shift($files));
}
}
Expand Down
2 changes: 2 additions & 0 deletions lib/Cake/Test/Case/Log/Engine/FileLogTest.php
Expand Up @@ -117,6 +117,8 @@ public function testRotation() {
$result = file_get_contents($files[1]);
$this->assertRegExp('/Warning: Test warning second/', $result);

file_put_contents($path . 'error.log.0000000000', "The oldest log file with over 35 bytes.\n");

sleep(1);
clearstatcache();
$log->write('warning', 'Test warning fourth');
Expand Down

0 comments on commit 83d340a

Please sign in to comment.