diff --git a/app/Http/Middleware/QueryLogging.php b/app/Http/Middleware/QueryLogging.php index a41de37b2cb2..fd0a9f310395 100644 --- a/app/Http/Middleware/QueryLogging.php +++ b/app/Http/Middleware/QueryLogging.php @@ -37,22 +37,25 @@ class QueryLogging if (! Ninja::isHosted() || ! config('beacon.enabled')) { return $next($request); } + + DB::enableQueryLog(); + return $next($request); + + } + + public function terminate($request, $response) + { $timeStart = microtime(true); - DB::enableQueryLog(); - $response = $next($request); // hide requests made by debugbar if (strstr($request->url(), '_debugbar') === false) { + $queries = DB::getQueryLog(); $count = count($queries); $timeEnd = microtime(true); $time = $timeEnd - $timeStart; - // nlog("Query count = {$count}"); - // nlog($queries); - // nlog($request->url()); - if ($count > 175) { nlog("Query count = {$count}"); nlog($queries); @@ -60,18 +63,17 @@ class QueryLogging $ip = ''; - if (request()->hasHeader('Cf-Connecting-Ip')) { - $ip = request()->header('Cf-Connecting-Ip'); - } elseif (request()->hasHeader('X-Forwarded-For')) { - $ip = request()->header('Cf-Connecting-Ip'); + if ($request->hasHeader('Cf-Connecting-Ip')) { + $ip = $request->header('Cf-Connecting-Ip'); + } elseif ($request->hasHeader('X-Forwarded-For')) { + $ip = $request->header('Cf-Connecting-Ip'); } else { - $ip = request()->ip(); + $ip = $request->ip(); } LightLogs::create(new DbQuery($request->method(), substr(urldecode($request->url()), 0, 180), $count, $time, $ip)) - ->batch(); + ->batch(); } - return $response; } } diff --git a/app/Jobs/Invoice/CheckGatewayFee.php b/app/Jobs/Invoice/CheckGatewayFee.php index 32ee5ad30a10..e7a978427045 100644 --- a/app/Jobs/Invoice/CheckGatewayFee.php +++ b/app/Jobs/Invoice/CheckGatewayFee.php @@ -41,7 +41,6 @@ class CheckGatewayFee implements ShouldQueue */ public function handle() { - nlog("Checking Gateway Fees for Invoice Id = {$this->invoice_id}"); MultiDB::setDb($this->db);