A logger that can add job debug information to the log messages

We use the second argument, $context, to send jobs to the logger. If the caller includes a job object in the $context, we presume it wants to add details about the job, so we add a debug level message with the job details.

To add job details to any log message, just add this to the second argument, $context:

$context[JobLogger::JOB_INDEX] = $job;

I have considered three solutions: - Adding a Monolog processor and a handler - Inheriting the Monolog logger and overriding parent methods - Encapsulating the logger and calling it as a dependency

I have ruled out the first solution, because we want to emit two messages from one call and neither a handler or a processor are the right place. I have tried the second solution, inheritance, but the constructor was complex and unit testing was not easy without mocking the tested class. In the end I have decided to use composition and encapsulate the original logger.

Type hierarchy

redweb-tn/codeigniter4 dev-master 4.0
resque/yii2-resque dev-master
rkr/amazon-pay-sdk-php 2.x-dev
struggle-for-php/sfp-psalm-psr-log-plugin dev-master 0.2.0
zire/psr-log dev-master 1.1.4

Class usage:

This class is used in:
Class Package
disqontrol/disqontrol dev-master
disqontrol/disqontrol 0.3.3
disqontrol/disqontrol 0.3.3
disqontrol/disqontrol 0.3.3
disqontrol/disqontrol 0.3.3