<?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; use ModStart\Core\Util\SerializeUtil; class HttpMonitor { public static function init() { goto IiQTp; t3Iky: if (class_exists('Illuminate\\Foundation\\Http\\Events\\RequestHandled')) { $Vpwev = 'Illuminate\\Foundation\\Http\\Events\\RequestHandled'; } goto F2LhT; F2LhT: Event::listen($Vpwev, function ($pGa3o = null, $FqOmX = null) use($Vpwev) { if (!defined('LARAVEL_START')) { return; } $hoJyG = $pGa3o; if ($Vpwev == 'kernel.handled') { } else { $hoJyG = $pGa3o->request; $FqOmX = $pGa3o->response; } $vQlXM = round((microtime(true) - LARAVEL_START) * 1000, 2); $ik1Qg = $hoJyG->url(); $pK00s = $hoJyG->method(); if (class_exists('\\ModStart\\Core\\Events\\ModStartRequestHandled')) { goto Lyytm; x6jOx: $Xlb8r->time = $vQlXM; goto UKoDa; H2Yxc: $Xlb8r->url = $hoJyG->path(); goto AhSVy; DhRR0: EventUtil::fire($Xlb8r); goto cRCgT; vir5w: if (method_exists($FqOmX, 'status')) { $Xlb8r->statusCode = $FqOmX->status(); } else { if (method_exists($FqOmX, 'getStatusCode')) { $Xlb8r->statusCode = $FqOmX->getStatusCode(); } } goto DhRR0; ygX4N: $Xlb8r->response = $FqOmX; goto vir5w; UKoDa: $Xlb8r->statusCode = 0; goto ygX4N; AhSVy: $Xlb8r->method = $pK00s; goto x6jOx; Lyytm: $Xlb8r = new ModStartRequestHandled(); goto H2Yxc; cRCgT: } if (!config('modstart.trackPerformance', false)) { return; } $Z_RvH = DatabaseMonitor::getQueryCountPerRequest(); $ACVUe = '{}'; if ($vQlXM > 5000 || $Z_RvH > 30) { $ACVUe = ArrayUtil::serializeForLog($hoJyG->input()); } if ($vQlXM > 5000) { Log::warning("LONG_REQUEST {$pK00s} [{$ik1Qg}] {$vQlXM}ms {$ACVUe}"); } if ($Z_RvH > 30) { Log::warning("MASS_REQUEST_SQL {$pK00s} [{$ik1Qg}] {$Z_RvH} {$ACVUe} -> " . SerializeUtil::jsonEncode(DatabaseMonitor::getQueryCountPerRequestSqls())); } }); goto Byj87; IiQTp: $Vpwev = 'kernel.handled'; goto t3Iky; Byj87: } }