Add support to get more information on the job class
iahmedsuhail opened this issue · 0 comments
Currently, Job Middleware has the WithoutOverlapping
amongst some other middlewares. It would be useful to have something that would allow accessing important information from the job, like the name of the job that was called, and the attributes of the class.
This would mean that I could use middleware to Log all important information about a job and send those logs to other places, maybe using the Log support.
I tried writing something on my own, but it looks like the $job
attribute you get in the middleware isn't very useful and can only be used to pass it to the callback amongst some information (doesn't have much information that is accessible).
<?php
namespace App\Jobs\Middleware;
class Log
{
/**
* Logs the job and its details before and after processing a job.
*
* @param mixed $job
* @param callable $next
* @return mixed
*/
public function handle($job, $next)
{
// $job isn't very useful here
}
}
Some useful attributes that can be made available on the job can be the name of the class, the payload the job was called with, etc.