mirror of
https://github.com/librenms/librenms.git
synced 2024-09-22 02:48:37 +00:00
014213680f
* Move Config loading to a service provider That way other service providers can depend on it Move various random listener registrations into the EventServiceProvider Various startup cleanup * Config::persist Set live variable before persisting incase db update fail * Disable strict mode for legacy code (init.php) * Disable debug after os test data is gathered * remove Eloquent::boot it is never used * remove Eloquent::version * lint fixes * style fixes * there is no c_echo here
44 lines
956 B
PHP
44 lines
956 B
PHP
<?php
|
|
|
|
namespace App\Listeners;
|
|
|
|
use Illuminate\Database\Events\QueryExecuted;
|
|
use LibreNMS\Util\Debug;
|
|
use Log;
|
|
|
|
class QueryDebugListener
|
|
{
|
|
/**
|
|
* Create the event listener.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Handle the event.
|
|
*
|
|
* @param \Illuminate\Database\Events\QueryExecuted $query
|
|
* @return void
|
|
*/
|
|
public function handle(QueryExecuted $query)
|
|
{
|
|
if (Debug::queryDebugIsEnabled()) {
|
|
|
|
// collect bindings and make them a little more readable
|
|
$bindings = collect($query->bindings)->map(function ($item) {
|
|
if ($item instanceof \Carbon\Carbon) {
|
|
return $item->toDateTimeString();
|
|
}
|
|
|
|
return $item;
|
|
})->toJson();
|
|
|
|
Log::debug("SQL[%Y{$query->sql} %y$bindings%n {$query->time}ms] \n", ['color' => true]);
|
|
}
|
|
}
|
|
}
|