改进日志写入并发问题

This commit is contained in:
thinkphp
2018-01-23 15:12:53 +08:00
parent 0050bc662f
commit 618fb51788

View File

@@ -86,7 +86,10 @@ class File
{ {
//检测日志文件大小,超过配置大小则备份日志文件重新生成 //检测日志文件大小,超过配置大小则备份日志文件重新生成
if (is_file($destination) && floor($this->config['file_size']) <= filesize($destination)) { if (is_file($destination) && floor($this->config['file_size']) <= filesize($destination)) {
rename($destination, dirname($destination) . DS . time() . '-' . basename($destination)); try {
rename($destination, dirname($destination) . DS . time() . '-' . basename($destination));
} catch (\Exception $e) {
}
$this->writed[$destination] = false; $this->writed[$destination] = false;
} }