mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-14 07:02:34 +01:00
0fbda85a59
- Removed unused uses - Type hinting for method parameters - Removed commented code - Introduced comments for classes and methods - Short array syntax
42 lines
920 B
PHP
42 lines
920 B
PHP
<?php namespace App\Http\Middleware;
|
|
|
|
use DB;
|
|
use Illuminate\Http\Request;
|
|
use Log;
|
|
use Utils;
|
|
use Closure;
|
|
|
|
/**
|
|
* Class QueryLogging
|
|
*/
|
|
class QueryLogging
|
|
{
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param Request $request
|
|
* @param Closure $next
|
|
* @return mixed
|
|
*/
|
|
public function handle(Request $request, Closure $next)
|
|
{
|
|
// Enable query logging for development
|
|
if (Utils::isNinjaDev()) {
|
|
DB::enableQueryLog();
|
|
}
|
|
|
|
$response = $next($request);
|
|
|
|
if (Utils::isNinjaDev()) {
|
|
// hide requests made by debugbar
|
|
if (strstr($request->url(), '_debugbar') === false) {
|
|
$queries = DB::getQueryLog();
|
|
$count = count($queries);
|
|
Log::info($request->method() . ' - ' . $request->url() . ": $count queries");
|
|
}
|
|
}
|
|
|
|
return $response;
|
|
}
|
|
}
|