mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 07:32:48 +08:00
单个日志文件支持大小设置
This commit is contained in:
@@ -20,10 +20,10 @@ class File
|
|||||||
{
|
{
|
||||||
protected $config = [
|
protected $config = [
|
||||||
'time_format' => ' c ',
|
'time_format' => ' c ',
|
||||||
|
'single' => false,
|
||||||
'file_size' => 2097152,
|
'file_size' => 2097152,
|
||||||
'path' => LOG_PATH,
|
'path' => LOG_PATH,
|
||||||
'apart_level' => [],
|
'apart_level' => [],
|
||||||
'single' => false,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $writed = [];
|
protected $writed = [];
|
||||||
@@ -84,7 +84,7 @@ class File
|
|||||||
protected function write($message, $destination, $apart = false)
|
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));
|
rename($destination, dirname($destination) . DS . time() . '-' . basename($destination));
|
||||||
$this->writed[$destination] = false;
|
$this->writed[$destination] = false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user