1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00
invoiceninja/app/Http/Middleware/QueryLogging.php
2016-05-13 12:08:41 +03:00

39 lines
939 B
PHP

<?php namespace App\Http\Middleware;
use DB;
use Log;
use Utils;
use Closure;
class QueryLogging
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($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");
//Log::info(json_encode($queries));
}
}
return $response;
}
}