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

psr/log dev-master 1.1.4
View more packages
mrcnpdlk/imdbphp v4.1.1
psr-php7/log dev-master 1.0.0
struggle-for-php/sfp-psalm-psr-log-plugin dev-master 0.2.0
amzn/amazon-pay-sdk-php 2.x-dev
amzn/login-and-pay-with-amazon-sdk-php 2.x-dev
cyan.tseng/logger dev-master
graef685/log 4.0.0 1.1.4
imdbphp/imdbphp v4.1.1
instituteweb/typo3-cms 6.2.31
integer-net/solr-base 1.0.4

Class usage:

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