| 1234567891011121314151617181920212223242526272829303132333435363738394041 | 
							- <?php
 
- declare (strict_types=1);
 
- namespace app\common\middleware;
 
- use app\common\model\AdminLog;
 
- use app\Request;
 
- use Closure;
 
- use think\facade\Log;
 
- /**
 
-  * 全局日志记录
 
-  * Class WriteLog
 
-  * @package app\middleware
 
-  */
 
- class WriteLog
 
- {
 
-     /**
 
-      * @param Request $request
 
-      * @param Closure $next
 
-      * @return mixed
 
-      */
 
-     public function handle(Request $request, Closure $next): mixed
 
-     {
 
-         $response = $next($request);
 
-         // 添加中间件执行代码
 
-         Log::record("===============" . getNow() . "全局日志记录===============", "debug");
 
-         Log::record("request:" . $request->url(true), "debug");
 
-         Log::record('REFERER  ' . (array_key_exists('HTTP_REFERER', $_SERVER) ? $_SERVER['HTTP_REFERER'] : ""));
 
-         Log::record('GET  ' . json_encode($_GET, JSON_UNESCAPED_UNICODE));
 
-         Log::record('POST  ' . json_encode($_POST, JSON_UNESCAPED_UNICODE));
 
-         Log::record('cookie  ' . json_encode($_COOKIE, JSON_UNESCAPED_UNICODE));
 
-         Log::record('param  ' . json_encode(input('param.'), JSON_UNESCAPED_UNICODE));
 
-         return $response;
 
-     }
 
- }
 
 
  |