<?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 dHpzk; erIvp: if (class_exists('Illuminate\\Foundation\\Http\\Events\\RequestHandled')) { $KIbLj = 'Illuminate\\Foundation\\Http\\Events\\RequestHandled'; } goto vVc43; vVc43: Event::listen($KIbLj, function ($mpXGF = null, $CqM8X = null) use($KIbLj) { if (!defined('LARAVEL_START')) { return; } $U5_Oe = $mpXGF; if ($KIbLj == 'kernel.handled') { } else { $U5_Oe = $mpXGF->request; $CqM8X = $mpXGF->response; } $aoDgD = round((microtime(true) - LARAVEL_START) * 1000, 2); $VzVt9 = $U5_Oe->url(); $HkVnj = $U5_Oe->method(); if (class_exists('\\ModStart\\Core\\Events\\ModStartRequestHandled')) { goto t80SR; x2KCl: $xpJqz->method = $HkVnj; goto zvksb; EzF1p: EventUtil::fire($xpJqz); goto MOIqp; t80SR: $xpJqz = new ModStartRequestHandled(); goto zIDXq; VuUQa: $xpJqz->response = $CqM8X; goto Llz80; Llz80: if (method_exists($CqM8X, 'status')) { $xpJqz->statusCode = $CqM8X->status(); } else { if (method_exists($CqM8X, 'getStatusCode')) { $xpJqz->statusCode = $CqM8X->getStatusCode(); } } goto EzF1p; dSv8A: $xpJqz->statusCode = 0; goto VuUQa; zIDXq: $xpJqz->url = $U5_Oe->path(); goto x2KCl; zvksb: $xpJqz->time = $aoDgD; goto dSv8A; MOIqp: } if (!config('modstart.trackPerformance', false)) { return; } $atvcv = DatabaseMonitor::getQueryCountPerRequest(); $oK4I3 = '{}'; if ($aoDgD > 5000 || $atvcv > 30) { $oK4I3 = ArrayUtil::serializeForLog($U5_Oe->input()); } if ($aoDgD > 5000) { Log::warning("LONG_REQUEST {$HkVnj} [{$VzVt9}] {$aoDgD}ms {$oK4I3}"); } if ($atvcv > 30) { Log::warning("MASS_REQUEST_SQL {$HkVnj} [{$VzVt9}] {$atvcv} {$oK4I3} -> " . json_encode(DatabaseMonitor::getQueryCountPerRequestSqls(), JSON_UNESCAPED_UNICODE)); } }); goto pXw51; dHpzk: $KIbLj = 'kernel.handled'; goto erIvp; pXw51: } }