|
|
@@ -201,17 +201,21 @@ class FileLog extends BaseLog {
|
|
|
}
|
|
|
|
|
|
if ($this->_config['rotate'] === 0) {
|
|
|
- return unlink($filepath);
|
|
|
+ $result = unlink($filepath);
|
|
|
+ } else {
|
|
|
+ $result = rename($filepath, $filepath . '.' . time());
|
|
|
}
|
|
|
|
|
|
- if ($this->_config['rotate']) {
|
|
|
- $files = glob($filepath . '.*');
|
|
|
- while (count($files) >= $this->_config['rotate']) {
|
|
|
+ $files = glob($filepath . '.*');
|
|
|
+ if ($files) {
|
|
|
+ $filesToDelete = count($files) - $this->_config['rotate'];
|
|
|
+ while ($filesToDelete > 0) {
|
|
|
unlink(array_shift($files));
|
|
|
+ $filesToDelete--;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return rename($filepath, $filepath . '.' . time());
|
|
|
+ return $result;
|
|
|
}
|
|
|
|
|
|
}
|