-
-
Notifications
You must be signed in to change notification settings - Fork 74
Open
Description
I created the below event listener and bound it to the QueryExecuted event.
<?php
namespace App\Listeners;
use Illuminate\Database\Events\QueryExecuted;
use Illuminate\Support\Facades\Log;
class QueryExecutedListener
{
/**
* Create the event listener.
*/
public function __construct()
{
//
}
/**
* Handle the event.
*/
public function handle(QueryExecuted $query): void
{
$message = [
'query' => $query->sql,
'bindings' => $query->bindings,
'time' => $query->time
];
Log::error(json_encode($message));
}
}
but no log is saved to the channel after a query ran.
The listener is registered successfully which I can verify with the command php artisan event:list
Illuminate\Database\Events\QueryExecuted .........................................................................................................
⇂ Sentry\Laravel\EventHandler@queryExecuted
⇂ Sentry\Laravel\Tracing\EventHandler@queryExecuted
⇂ Spatie\LaravelIgnition\Recorders\QueryRecorder\QueryRecorder@record
⇂ App\Listeners\QueryExecutedListener@handle
This may because in Illuminate\Database\Connection class function event(), $this->events is always return null.
May I have a pointer how I can set the events properly?
Metadata
Metadata
Assignees
Labels
No labels