更新tp5内核
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
namespace think\log\driver;
|
||||
|
||||
use think\App;
|
||||
use think\Request;
|
||||
|
||||
/**
|
||||
* 本地化调试输出到文件
|
||||
@@ -20,6 +21,7 @@ class File
|
||||
{
|
||||
protected $config = [
|
||||
'time_format' => ' c ',
|
||||
'single' => false,
|
||||
'file_size' => 2097152,
|
||||
'path' => LOG_PATH,
|
||||
'apart_level' => [],
|
||||
@@ -43,8 +45,12 @@ class File
|
||||
*/
|
||||
public function save(array $log = [])
|
||||
{
|
||||
$cli = IS_CLI ? '_cli' : '';
|
||||
$destination = $this->config['path'] . date('Ym') . DS . date('d') . $cli . '.log';
|
||||
if ($this->config['single']) {
|
||||
$destination = $this->config['path'] . 'single.log';
|
||||
} else {
|
||||
$cli = IS_CLI ? '_cli' : '';
|
||||
$destination = $this->config['path'] . date('Ym') . DS . date('d') . $cli . '.log';
|
||||
}
|
||||
|
||||
$path = dirname($destination);
|
||||
!is_dir($path) && mkdir($path, 0755, true);
|
||||
@@ -60,7 +66,11 @@ class File
|
||||
}
|
||||
if (in_array($type, $this->config['apart_level'])) {
|
||||
// 独立记录的日志级别
|
||||
$filename = $path . DS . date('d') . '_' . $type . $cli . '.log';
|
||||
if ($this->config['single']) {
|
||||
$filename = $path . DS . $type . '.log';
|
||||
} else {
|
||||
$filename = $path . DS . date('d') . '_' . $type . $cli . '.log';
|
||||
}
|
||||
$this->write($level, $filename, true);
|
||||
} else {
|
||||
$info .= $level;
|
||||
@@ -99,11 +109,10 @@ class File
|
||||
$message = '[ info ] ' . $current_uri . $time_str . $memory_str . $file_load . "\r\n" . $message;
|
||||
}
|
||||
$now = date($this->config['time_format']);
|
||||
$server = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '0.0.0.0';
|
||||
$remote = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '0.0.0.0';
|
||||
$ip = Request::instance()->ip();
|
||||
$method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'CLI';
|
||||
$uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
|
||||
$message = "---------------------------------------------------------------\r\n[{$now}] {$server} {$remote} {$method} {$uri}\r\n" . $message;
|
||||
$message = "---------------------------------------------------------------\r\n[{$now}] {$ip} {$method} {$uri}\r\n" . $message;
|
||||
|
||||
$this->writed[$destination] = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user