<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Monitor; use Illuminate\Http\Request; use Illuminate\Http\Response; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Log; use ModStart\Core\Events\ModStartRequestHandled; use ModStart\Core\Util\ArrayUtil; use ModStart\Core\Util\EventUtil; class HttpMonitor { public static function init() { goto gvXRu; d5Wj_: if (class_exists('Illuminate\\Foundation\\Http\\Events\\RequestHandled')) { $tv6TU = 'Illuminate\\Foundation\\Http\\Events\\RequestHandled'; } goto xllNd; gvXRu: $tv6TU = 'kernel.handled'; goto d5Wj_; xllNd: Event::listen($tv6TU, function ($gQwRg = null, $mf4Oy = null) use($tv6TU) { if (!defined('LARAVEL_START')) { return; } $cSn43 = $gQwRg; if ($tv6TU == 'kernel.handled') { } else { $cSn43 = $gQwRg->request; $mf4Oy = $gQwRg->response; } $ANM3E = round((microtime(true) - LARAVEL_START) * 1000, 2); $YjgEW = $cSn43->url(); $HxDDI = $cSn43->method(); if (class_exists('\\ModStart\\Core\\Events\\ModStartRequestHandled')) { goto CDO_m; PDeH_: $Y5fnH->url = $cSn43->path(); goto ZOVr2; VWjF9: $Y5fnH->time = $ANM3E; goto GW3u1; IDTXq: if (method_exists($mf4Oy, 'status')) { $Y5fnH->statusCode = $mf4Oy->status(); } else { if (method_exists($mf4Oy, 'getStatusCode')) { $Y5fnH->statusCode = $mf4Oy->getStatusCode(); } } goto V9RCk; CDO_m: $Y5fnH = new ModStartRequestHandled(); goto PDeH_; GW3u1: $Y5fnH->statusCode = 0; goto W6MUn; W6MUn: $Y5fnH->response = $mf4Oy; goto IDTXq; V9RCk: EventUtil::fire($Y5fnH); goto TrZ6N; ZOVr2: $Y5fnH->method = $HxDDI; goto VWjF9; TrZ6N: } if (!config('modstart.trackPerformance', false)) { return; } $ExiFY = DatabaseMonitor::getQueryCountPerRequest(); $zlK8N = '{}'; if ($ANM3E > 5000 || $ExiFY > 30) { $zlK8N = ArrayUtil::serializeForLog($cSn43->input()); } if ($ANM3E > 5000) { Log::warning("LONG_REQUEST {$HxDDI} [{$YjgEW}] {$ANM3E}ms {$zlK8N}"); } if ($ExiFY > 30) { Log::warning("MASS_REQUEST_SQL {$HxDDI} [{$YjgEW}] {$ExiFY} {$zlK8N} -> " . json_encode(DatabaseMonitor::getQueryCountPerRequestSqls(), JSON_UNESCAPED_UNICODE)); } }); goto T8Gi5; T8Gi5: } }