<?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 LAwG9; LAwG9: $YDxDq = 'kernel.handled'; goto MkYHI; xBHFP: Event::listen($YDxDq, function ($K0adC = null, $i1_1k = null) use($YDxDq) { if (!defined('LARAVEL_START')) { return; } $MRMCA = $K0adC; if ($YDxDq == 'kernel.handled') { } else { $MRMCA = $K0adC->request; $i1_1k = $K0adC->response; } $gmNPm = round((microtime(true) - LARAVEL_START) * 1000, 2); $xIfit = $MRMCA->url(); $JHYOH = $MRMCA->method(); if (class_exists('\\ModStart\\Core\\Events\\ModStartRequestHandled')) { goto puTrO; kmNpM: if (method_exists($i1_1k, 'status')) { $SXS9c->statusCode = $i1_1k->status(); } else { if (method_exists($i1_1k, 'getStatusCode')) { $SXS9c->statusCode = $i1_1k->getStatusCode(); } } goto JuhG8; puTrO: $SXS9c = new ModStartRequestHandled(); goto pecEj; njQam: $SXS9c->method = $JHYOH; goto yxQWK; JuhG8: EventUtil::fire($SXS9c); goto Foe3i; yxQWK: $SXS9c->time = $gmNPm; goto r_WXK; pecEj: $SXS9c->url = $MRMCA->path(); goto njQam; r_WXK: $SXS9c->statusCode = 0; goto o10W1; o10W1: $SXS9c->response = $i1_1k; goto kmNpM; Foe3i: } if (!config('modstart.trackPerformance', false)) { return; } $R43r5 = DatabaseMonitor::getQueryCountPerRequest(); $Kp99R = array(); if ($gmNPm > 1000 || $R43r5 > 10) { $Kp99R = ArrayUtil::serializeForLog($MRMCA->input()); } if ($gmNPm > 1000) { Log::warning("LONG_REQUEST {$JHYOH} [{$xIfit}] {$gmNPm}ms {$Kp99R}"); } if ($R43r5 > 10) { Log::warning("MASS_REQUEST_SQL {$JHYOH} [{$xIfit}] {$R43r5} {$Kp99R} -> " . json_encode(DatabaseMonitor::getQueryCountPerRequestSqls(), JSON_UNESCAPED_UNICODE)); } }); goto FWNfm; MkYHI: if (class_exists('Illuminate\\Foundation\\Http\\Events\\RequestHandled')) { $YDxDq = 'Illuminate\\Foundation\\Http\\Events\\RequestHandled'; } goto xBHFP; FWNfm: } }