Created
December 12, 2023 20:32
-
-
Save chrismcintosh/af034c03dea9b8828cc008b3334f2985 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/****************************************************************************************************** | |
* Job Event Listeners | |
* https://github.com/laravel/framework/tree/10.x/src/Illuminate/Queue/Events | |
*/ | |
Event::listen(function (JobTimedOut $event) { | |
Log::warning("Job Timed Out: {$event->job->resolveName()}", [ | |
'job_uuid' => $event->job->uuid(), | |
'attempts' => $event->job->attempts(), | |
]); | |
}); | |
Event::listen(function (JobFailed $event) { | |
Log::critical("Job Failed: {$event->job->resolveName()}", [ | |
'job_uuid' => $event->job->uuid(), | |
'attempts' => $event->job->attempts(), | |
'exception' => $event->exception->getMessage(), | |
'exception_trace' => $event->exception->getTraceAsString(), | |
]); | |
}); | |
Event::listen(function (JobReleasedAfterException $event) { | |
Log::warning("Job Released Back to Queue due to exception in: {$event->job->resolveName()}", [ | |
'job_uuid' => $event->job->uuid(), | |
'attempts' => $event->job->attempts(), | |
]); | |
}); | |
Event::listen(function (JobExceptionOccurred $event) { | |
Log::error("Job Exception Occurred: {$event->job->resolveName()}", [ | |
'job_uuid' => $event->job->uuid(), | |
'attempts' => $event->job->attempts(), | |
'exception' => $event->exception->getMessage(), | |
'exception_trace' => $event->exception->getTraceAsString(), | |
]); | |
}); | |
Event::listen(function (JobProcessing $event) { | |
Log::info("Job Processing: {$event->job->resolveName()} ID: {$event->job->uuid()} Attempts: {$event->job->attempts()}", [ | |
'job_uuid' => $event->job->uuid(), | |
'attempts' => $event->job->attempts(), | |
]); | |
}); | |
Event::listen(function (JobRetryRequested $event) { | |
Log::warning("Job Retry Requested"); | |
}); | |
Event::listen(function (JobQueued $event) { | |
Log::debug("Job Queued: {$event->id}"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment