<?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 C41jf; wfY6X: Event::listen($kh6Oz, function ($M6PEW = null, $IB0nv = null) use($kh6Oz) { if (!defined('LARAVEL_START')) { return; } $Mjv3h = $M6PEW; if ($kh6Oz == 'kernel.handled') { } else { $Mjv3h = $M6PEW->request; $IB0nv = $M6PEW->response; } $sEFWu = round((microtime(true) - LARAVEL_START) * 1000, 2); $m2Dmo = $Mjv3h->url(); $fSCUf = $Mjv3h->method(); if (class_exists('\\ModStart\\Core\\Events\\ModStartRequestHandled')) { goto VCoPY; lL3vU: EventUtil::fire($WVwSN); goto vZrAB; ZfyTm: $WVwSN->time = $sEFWu; goto n8P1m; vgRGz: $WVwSN->url = $Mjv3h->path(); goto YqU21; VCoPY: $WVwSN = new ModStartRequestHandled(); goto vgRGz; YqU21: $WVwSN->method = $fSCUf; goto ZfyTm; o1g8S: if (method_exists($IB0nv, 'status')) { $WVwSN->statusCode = $IB0nv->status(); } else { if (method_exists($IB0nv, 'getStatusCode')) { $WVwSN->statusCode = $IB0nv->getStatusCode(); } } goto lL3vU; fW5iF: $WVwSN->response = $IB0nv; goto o1g8S; n8P1m: $WVwSN->statusCode = 0; goto fW5iF; vZrAB: } if (!config('modstart.trackPerformance', false)) { return; } $Q8TJ9 = DatabaseMonitor::getQueryCountPerRequest(); $qHLCM = '{}'; if ($sEFWu > 5000 || $Q8TJ9 > 30) { $qHLCM = ArrayUtil::serializeForLog($Mjv3h->input()); } if ($sEFWu > 5000) { Log::warning("LONG_REQUEST {$fSCUf} [{$m2Dmo}] {$sEFWu}ms {$qHLCM}"); } if ($Q8TJ9 > 30) { Log::warning("MASS_REQUEST_SQL {$fSCUf} [{$m2Dmo}] {$Q8TJ9} {$qHLCM} -> " . json_encode(DatabaseMonitor::getQueryCountPerRequestSqls(), JSON_UNESCAPED_UNICODE)); } }); goto HJncr; c6Iqn: if (class_exists('Illuminate\\Foundation\\Http\\Events\\RequestHandled')) { $kh6Oz = 'Illuminate\\Foundation\\Http\\Events\\RequestHandled'; } goto wfY6X; C41jf: $kh6Oz = 'kernel.handled'; goto c6Iqn; HJncr: } }