From d1a1ee55dca33feab5ead6748bcb4665fc715f26 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 29 May 2023 08:07:39 +1000 Subject: [PATCH] Move query logging into terminate method --- app/Http/Middleware/QueryLogging.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Http/Middleware/QueryLogging.php b/app/Http/Middleware/QueryLogging.php index fd0a9f310395..5350186a3c2f 100644 --- a/app/Http/Middleware/QueryLogging.php +++ b/app/Http/Middleware/QueryLogging.php @@ -23,6 +23,7 @@ use Turbo124\Beacon\Facades\LightLogs; */ class QueryLogging { + /** * Handle an incoming request. * @@ -33,6 +34,7 @@ class QueryLogging */ public function handle(Request $request, Closure $next) { + // Enable query logging for development if (! Ninja::isHosted() || ! config('beacon.enabled')) { return $next($request); @@ -45,8 +47,8 @@ class QueryLogging public function terminate($request, $response) { - - $timeStart = microtime(true); + if (! Ninja::isHosted() || ! config('beacon.enabled')) { + return; // hide requests made by debugbar if (strstr($request->url(), '_debugbar') === false) { @@ -54,7 +56,7 @@ class QueryLogging $queries = DB::getQueryLog(); $count = count($queries); $timeEnd = microtime(true); - $time = $timeEnd - $timeStart; + $time = $timeEnd - LARAVEL_START; if ($count > 175) { nlog("Query count = {$count}");