<?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 mtaum; mtaum: $UP57w = 'kernel.handled'; goto yTMKT; NYidr: Event::listen($UP57w, function ($jBvVt = null, $HMP0x = null) use($UP57w) { if (!defined('LARAVEL_START')) { return; } $gSoa2 = $jBvVt; if ($UP57w == 'kernel.handled') { } else { $gSoa2 = $jBvVt->request; $HMP0x = $jBvVt->response; } $oWzL0 = round((microtime(true) - LARAVEL_START) * 1000, 2); $iERFh = $gSoa2->url(); $hiFdg = $gSoa2->method(); if (class_exists('\\ModStart\\Core\\Events\\ModStartRequestHandled')) { goto ZVkgD; o5yqe: if (method_exists($HMP0x, 'status')) { $tZVhb->statusCode = $HMP0x->status(); } else { if (method_exists($HMP0x, 'getStatusCode')) { $tZVhb->statusCode = $HMP0x->getStatusCode(); } } goto Hd3sU; Hd3sU: EventUtil::fire($tZVhb); goto Q11i7; TXf6g: $tZVhb->url = $gSoa2->path(); goto ZI1RE; YErwt: $tZVhb->statusCode = 0; goto MVI_Z; mzZqV: $tZVhb->time = $oWzL0; goto YErwt; ZI1RE: $tZVhb->method = $hiFdg; goto mzZqV; MVI_Z: $tZVhb->response = $HMP0x; goto o5yqe; ZVkgD: $tZVhb = new ModStartRequestHandled(); goto TXf6g; Q11i7: } if (!config('modstart.trackPerformance', false)) { return; } $Putcr = DatabaseMonitor::getQueryCountPerRequest(); $pFM9U = '{}'; if ($oWzL0 > 5000 || $Putcr > 30) { $pFM9U = ArrayUtil::serializeForLog($gSoa2->input()); } if ($oWzL0 > 5000) { Log::warning("LONG_REQUEST {$hiFdg} [{$iERFh}] {$oWzL0}ms {$pFM9U}"); } if ($Putcr > 30) { Log::warning("MASS_REQUEST_SQL {$hiFdg} [{$iERFh}] {$Putcr} {$pFM9U} -> " . json_encode(DatabaseMonitor::getQueryCountPerRequestSqls(), JSON_UNESCAPED_UNICODE)); } }); goto bO7QS; yTMKT: if (class_exists('Illuminate\\Foundation\\Http\\Events\\RequestHandled')) { $UP57w = 'Illuminate\\Foundation\\Http\\Events\\RequestHandled'; } goto NYidr; bO7QS: } }