单个日志文件支持大小设置

This commit is contained in:
thinkphp
2017-11-16 15:43:21 +08:00
parent e6d0685433
commit 9f8b4f9357

View File

@@ -20,10 +20,10 @@ class File
{
protected $config = [
'time_format' => ' c ',
'single' => false,
'file_size' => 2097152,
'path' => LOG_PATH,
'apart_level' => [],
'single' => false,
];
protected $writed = [];
@@ -84,7 +84,7 @@ class File
protected function write($message, $destination, $apart = false)
{
//检测日志文件大小,超过配置大小则备份日志文件重新生成
if (!$this->config['single'] && 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));
$this->writed[$destination] = false;
}