Analyzing class Disqontrol\Logger\JobLogger
Description
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
-
disqontrol/disqontrol 0.3.3
Class usage:
This class is used in:Class | Package |
---|---|
Disqontrol\Logger\LineFormatter |
disqontrol/disqontrol
dev-master
|
Disqontrol\Logger\LineFormatter |
disqontrol/disqontrol
0.3.3
|
Disqontrol\Disque\FailJob |
disqontrol/disqontrol
0.3.3
|
Disqontrol\Disque\AddJob |
disqontrol/disqontrol
0.3.3
|
Disqontrol\Dispatcher\Failure\LogAndThrowAway |
disqontrol/disqontrol
0.3.3
|