Tuesday, 24 December 2019

How to customize the log output for a job in Laravel?

I see that Laravel uses Monolog lib to handle logs. I have the following handle method in the job:

ApiUpdateItemJob.php:

public function handle()
{
$data = [
'id' => $this->item_id,
'data[status]' => $this->status,
];

$response = ApiFacedeClient::exec('Item', 'update', $data);

$result = json_decode($response->getBody());
}

In the worker's log (supervisor) I see the following:

[2019-12-17 02:13:13][40770367] Processed: App\Jobs\UpdateItemStatus
[2019-12-17 05:11:53][40792760] Processing: App\Jobs\UpdateItemStatus
[2019-12-17 05:11:54][40792761] Processing: App\Jobs\UpdateItemStatus
[2019-12-17 05:11:54][40792760] Processed: App\Jobs\UpdateItemStatus
[2019-12-17 05:11:54][40792762] Processing: App\Jobs\UpdateItemStatus

What should I add to the job to see the following line:

[2019-12-17 05:11:54][40792762] Processing item id #333333 (Status [200 OK]): App\Jobs\UpdateItemStatus



from How to customize the log output for a job in Laravel?

No comments:

Post a Comment