mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 07:32:48 +08:00
改进文件缓存和日志的存储文件名命名规范
This commit is contained in:
22
library/think/cache/driver/File.php
vendored
22
library/think/cache/driver/File.php
vendored
@@ -69,19 +69,17 @@ class File
|
|||||||
$name = md5($name);
|
$name = md5($name);
|
||||||
if ($this->options['cache_subdir']) {
|
if ($this->options['cache_subdir']) {
|
||||||
// 使用子目录
|
// 使用子目录
|
||||||
$dir = '';
|
$name = substr($md5, 0, 2) . DS . substr($md5, 2);
|
||||||
$len = $this->options['path_level'];
|
|
||||||
for ($i = 0; $i < $len; $i++) {
|
|
||||||
$dir .= $name{$i} . DS;
|
|
||||||
}
|
|
||||||
if (!is_dir($this->options['path'] . $dir)) {
|
|
||||||
mkdir($this->options['path'] . $dir, 0755, true);
|
|
||||||
}
|
|
||||||
$filename = $dir . $this->options['prefix'] . $name . '.php';
|
|
||||||
} else {
|
|
||||||
$filename = $this->options['prefix'] . $name . '.php';
|
|
||||||
}
|
}
|
||||||
return $this->options['path'] . $filename;
|
if ($this->options['prefix']) {
|
||||||
|
$name = $this->options['prefix'] . DS . $name;
|
||||||
|
}
|
||||||
|
$filename = $this->options['path'] . $name . '.php';
|
||||||
|
$dir = dirname($filename);
|
||||||
|
if (!is_dir($dir)) {
|
||||||
|
mkdir($dir, 0755, true);
|
||||||
|
}
|
||||||
|
return $filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -39,9 +39,10 @@ class File
|
|||||||
public function save(array $log = [])
|
public function save(array $log = [])
|
||||||
{
|
{
|
||||||
$now = date($this->config['time_format']);
|
$now = date($this->config['time_format']);
|
||||||
$destination = $this->config['path'] . date('y_m_d') . '.log';
|
$destination = $this->config['path'] . date('Ym') . DS . date('d') . '.log';
|
||||||
|
|
||||||
!is_dir($this->config['path']) && mkdir($this->config['path'], 0755, true);
|
$path = dirname($destination);
|
||||||
|
!is_dir($path) && mkdir($path, 0755, true);
|
||||||
|
|
||||||
//检测日志文件大小,超过配置大小则备份日志文件重新生成
|
//检测日志文件大小,超过配置大小则备份日志文件重新生成
|
||||||
if (is_file($destination) && floor($this->config['file_size']) <= filesize($destination)) {
|
if (is_file($destination) && floor($this->config['file_size']) <= filesize($destination)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user