mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
改进日志记录的ip地址
This commit is contained in:
@@ -1265,7 +1265,7 @@ class Request
|
||||
* @param boolean $adv 是否进行高级模式获取(有可能被伪装)
|
||||
* @return mixed
|
||||
*/
|
||||
public function ip($type = 0, $adv = false)
|
||||
public function ip($type = 0, $adv = true)
|
||||
{
|
||||
$type = $type ? 1 : 0;
|
||||
static $ip = null;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
namespace think\log\driver;
|
||||
|
||||
use think\App;
|
||||
use think\Request;
|
||||
|
||||
/**
|
||||
* 本地化调试输出到文件
|
||||
@@ -108,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