<?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 FSFIo; Chtet: if (class_exists('Illuminate\\Foundation\\Http\\Events\\RequestHandled')) { $OeByj = 'Illuminate\\Foundation\\Http\\Events\\RequestHandled'; } goto jBRmp; FSFIo: $OeByj = 'kernel.handled'; goto Chtet; jBRmp: Event::listen($OeByj, function ($p4Rr6 = null, $YD5di = null) use($OeByj) { if (!defined('LARAVEL_START')) { return; } $fzeTQ = $p4Rr6; if ($OeByj == 'kernel.handled') { } else { $fzeTQ = $p4Rr6->request; $YD5di = $p4Rr6->response; } $CoZv2 = round((microtime(true) - LARAVEL_START) * 1000, 2); $tpgiq = $fzeTQ->url(); $fVu6a = $fzeTQ->method(); if (class_exists('\\ModStart\\Core\\Events\\ModStartRequestHandled')) { goto QvdJy; QvdJy: $SwVsw = new ModStartRequestHandled(); goto U7Z23; aQ0uz: if (method_exists($YD5di, 'status')) { $SwVsw->statusCode = $YD5di->status(); } else { if (method_exists($YD5di, 'getStatusCode')) { $SwVsw->statusCode = $YD5di->getStatusCode(); } } goto nbg32; XceD5: $SwVsw->method = $fVu6a; goto NXeeS; nbg32: EventUtil::fire($SwVsw); goto Nubdt; PjRMr: $SwVsw->statusCode = 0; goto hz8xC; U7Z23: $SwVsw->url = $fzeTQ->path(); goto XceD5; NXeeS: $SwVsw->time = $CoZv2; goto PjRMr; hz8xC: $SwVsw->response = $YD5di; goto aQ0uz; Nubdt: } if (!config('modstart.trackPerformance', false)) { return; } $DowdX = DatabaseMonitor::getQueryCountPerRequest(); $AXgEz = '{}'; if ($CoZv2 > 5000 || $DowdX > 30) { $AXgEz = ArrayUtil::serializeForLog($fzeTQ->input()); } if ($CoZv2 > 5000) { Log::warning("LONG_REQUEST {$fVu6a} [{$tpgiq}] {$CoZv2}ms {$AXgEz}"); } if ($DowdX > 30) { Log::warning("MASS_REQUEST_SQL {$fVu6a} [{$tpgiq}] {$DowdX} {$AXgEz} -> " . SerializeUtil::jsonEncode(DatabaseMonitor::getQueryCountPerRequestSqls())); } }); goto PMM92; PMM92: } }