diff --git a/src/app/Listeners/HorizonDebug.php b/src/app/Listeners/HorizonDebug.php new file mode 100644 index 00000000..adf84658 --- /dev/null +++ b/src/app/Listeners/HorizonDebug.php @@ -0,0 +1,62 @@ + + */ + public function subscribe(Dispatcher $events): array + { + if (!\config('app.debug')) { + return []; + } + + return [ + JobPushed::class => 'handle', + JobDeleted::class => 'handle', + JobReleased::class => 'handle', + JobReleased::class => 'handle', + JobsMigrated::class => 'handle' + ]; + } + + /** + * Handle the event. + * + * @param object $event An event object + */ + public function handle(object $event): void + { + $line = " Job: " . get_class($event); + $line .= " Queue: " . $event->queue; + $line .= " Connection: " . $event->connectionName; + \Log::debug("[Horizon] {$line}"); + } +} + + + +// Event::listen(JobPushed::class, function(JobPushed $event){ +// \Log::debug('JobPushed Event Fired ', [ +// 'connection' => $event->connectionName, +// 'queue' => $event->queue, +// 'payload' => [ +// 'id' => $event->payload->id(), +// 'displayName' => $event->payload->displayName(), +// 'commandName' => $event->payload->commandName(), +// 'isRetry' => $event->payload->isRetry(), +// 'retryOf' => $event->payload->retryOf(), +// ] +// ]); +// }); diff --git a/src/app/Providers/EventServiceProvider.php b/src/app/Providers/EventServiceProvider.php index c601180a..decc4777 100644 --- a/src/app/Providers/EventServiceProvider.php +++ b/src/app/Providers/EventServiceProvider.php @@ -1,41 +1,42 @@ > */ protected $listen = [ ]; /** * The subscriber classes to register. * * @var array */ protected $subscribe = [ \App\Listeners\SqlDebug::class, + \App\Listeners\HorizonDebug::class, ]; /** * Register any events for your application. */ public function boot(): void { // } /** * Determine if events and listeners should be automatically discovered. */ public function shouldDiscoverEvents(): bool { return false; } }