|
6 | 6 | use Enqueue\Client\ChainExtension as ClientChainExtensions;
|
7 | 7 | use Enqueue\Client\Config;
|
8 | 8 | use Enqueue\Client\ConsumptionExtension\DelayRedeliveredMessageExtension;
|
| 9 | +use Enqueue\Client\ConsumptionExtension\LogExtension; |
9 | 10 | use Enqueue\Client\ConsumptionExtension\SetRouterPropertiesExtension;
|
10 | 11 | use Enqueue\Client\DelegateProcessor;
|
11 | 12 | use Enqueue\Client\DriverFactory;
|
|
26 | 27 | use Enqueue\Rpc\RpcFactory;
|
27 | 28 | use Enqueue\Symfony\DependencyInjection\TransportFactory;
|
28 | 29 | use Interop\Queue\Processor;
|
| 30 | +use Psr\Log\LoggerInterface; |
| 31 | +use Psr\Log\NullLogger; |
29 | 32 | use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
30 | 33 | use Symfony\Component\Config\Definition\NodeInterface;
|
31 | 34 | use Symfony\Component\Config\Definition\Processor as ConfigProcessor;
|
@@ -57,6 +60,11 @@ final class SimpleClient
|
57 | 60 | */
|
58 | 61 | private $delegateProcessor;
|
59 | 62 |
|
| 63 | + /** |
| 64 | + * @var LoggerInterface |
| 65 | + */ |
| 66 | + private $logger; |
| 67 | + |
60 | 68 | /**
|
61 | 69 | * The config could be a transport DSN (string) or an array, here's an example of a few DSNs:.
|
62 | 70 | *
|
@@ -104,9 +112,11 @@ final class SimpleClient
|
104 | 112 | *
|
105 | 113 | * @param string|array $config
|
106 | 114 | */
|
107 |
| - public function __construct($config) |
| 115 | + public function __construct($config, LoggerInterface $logger = null) |
108 | 116 | {
|
109 | 117 | $this->build(['enqueue' => $config]);
|
| 118 | + |
| 119 | + $this->logger = $logger ?: new NullLogger(); |
110 | 120 | }
|
111 | 121 |
|
112 | 122 | /**
|
@@ -262,9 +272,10 @@ public function build(array $configs): void
|
262 | 272 | }
|
263 | 273 |
|
264 | 274 | $consumptionExtensions[] = new SetRouterPropertiesExtension($driver);
|
| 275 | + $consumptionExtensions[] = new LogExtension(); |
265 | 276 |
|
266 | 277 | $consumptionChainExtension = new ConsumptionChainExtension($consumptionExtensions);
|
267 |
| - $queueConsumer = new QueueConsumer($driver->getContext(), $consumptionChainExtension); |
| 278 | + $queueConsumer = new QueueConsumer($driver->getContext(), $consumptionChainExtension, [], $this->logger); |
268 | 279 |
|
269 | 280 | $routerProcessor = new RouterProcessor($driver);
|
270 | 281 |
|
|
0 commit comments