<?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 UTanb; Vx7MI: Event::listen($QDFT2, function ($iPBEV = null, $aziFu = null) use($QDFT2) { if (!defined('LARAVEL_START')) { return; } $Kv_Mp = $iPBEV; if ($QDFT2 == 'kernel.handled') { } else { $Kv_Mp = $iPBEV->request; $aziFu = $iPBEV->response; } $EjkFa = round((microtime(true) - LARAVEL_START) * 1000, 2); $MiLaY = $Kv_Mp->url(); $UVOMF = $Kv_Mp->method(); if (class_exists('\\ModStart\\Core\\Events\\ModStartRequestHandled')) { goto RVePI; nufSo: $Sgh1N->time = $EjkFa; goto wK562; RVePI: $Sgh1N = new ModStartRequestHandled(); goto ntdFO; BJLnw: $Sgh1N->method = $UVOMF; goto nufSo; ntdFO: $Sgh1N->url = $Kv_Mp->path(); goto BJLnw; wK562: $Sgh1N->statusCode = 0; goto UkUeU; RFWCN: EventUtil::fire($Sgh1N); goto fxdbY; kwKL1: if (method_exists($aziFu, 'status')) { $Sgh1N->statusCode = $aziFu->status(); } else { if (method_exists($aziFu, 'getStatusCode')) { $Sgh1N->statusCode = $aziFu->getStatusCode(); } } goto RFWCN; UkUeU: $Sgh1N->response = $aziFu; goto kwKL1; fxdbY: } if (!config('modstart.trackPerformance', false)) { return; } $wmPZ9 = DatabaseMonitor::getQueryCountPerRequest(); $mattM = '{}'; if ($EjkFa > 5000 || $wmPZ9 > 30) { $mattM = ArrayUtil::serializeForLog($Kv_Mp->input()); } if ($EjkFa > 5000) { Log::warning("LONG_REQUEST {$UVOMF} [{$MiLaY}] {$EjkFa}ms {$mattM}"); } if ($wmPZ9 > 30) { Log::warning("MASS_REQUEST_SQL {$UVOMF} [{$MiLaY}] {$wmPZ9} {$mattM} -> " . SerializeUtil::jsonEncode(DatabaseMonitor::getQueryCountPerRequestSqls())); } }); goto Sj4Mk; hrE_A: if (class_exists('Illuminate\\Foundation\\Http\\Events\\RequestHandled')) { $QDFT2 = 'Illuminate\\Foundation\\Http\\Events\\RequestHandled'; } goto Vx7MI; UTanb: $QDFT2 = 'kernel.handled'; goto hrE_A; Sj4Mk: } }