TaoLer/app/middleware/Browse.php

21 lines
401 B
PHP
Raw Permalink Normal View History

2020-03-11 20:20:59 +08:00
<?php
namespace app\middleware;
2024-04-14 12:03:38 +08:00
2020-03-11 20:20:59 +08:00
use think\facade\Log;
2024-04-14 12:03:38 +08:00
/**
* 浏览记录日志中间件
*/
2020-03-11 20:20:59 +08:00
class Browse
{
public function handle($request, \Closure $next)
{
2024-04-01 10:24:38 +08:00
$agent = $request->header('user-agent');
$ip = $request->ip();
$url = $request->url(true);
2020-03-11 20:20:59 +08:00
Log::channel('browse')->info('browse:{agent} {ip} {url}',['agent'=>$agent,'url'=>$url,'ip'=>$ip]);
2024-04-01 10:24:38 +08:00
return $next($request);
2020-03-11 20:20:59 +08:00
}
}