|
13 | 13 |
|
14 | 14 | use InvalidArgumentException; |
15 | 15 | use Monolog\Attribute\AsMonologProcessor; |
| 16 | +use Monolog\Attribute\WithMonologChannel; |
16 | 17 | use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy; |
17 | 18 | use Monolog\Handler\RollbarHandler; |
18 | 19 | use Monolog\Logger; |
19 | 20 | use Monolog\Processor\UidProcessor; |
20 | | -use Symfony\Bridge\Monolog\Processor\SwitchUserTokenProcessor; |
21 | 21 | use Symfony\Bundle\MonologBundle\DependencyInjection\MonologExtension; |
22 | 22 | use Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\LoggerChannelPass; |
23 | 23 | use Symfony\Bundle\MonologBundle\Tests\DependencyInjection\Fixtures\AsMonologProcessor\FooProcessor; |
24 | 24 | use Symfony\Bundle\MonologBundle\Tests\DependencyInjection\Fixtures\AsMonologProcessor\FooProcessorWithPriority; |
25 | 25 | use Symfony\Bundle\MonologBundle\Tests\DependencyInjection\Fixtures\AsMonologProcessor\RedeclareMethodProcessor; |
| 26 | +use Symfony\Bundle\MonologBundle\Tests\DependencyInjection\Fixtures\ServiceWithChannel; |
26 | 27 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
27 | 28 | use Symfony\Component\DependencyInjection\Definition; |
28 | 29 | use Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag; |
@@ -837,6 +838,26 @@ public function testAsMonologProcessorAutoconfigurationWithPriority(): void |
837 | 838 | ], $container->getDefinition(FooProcessorWithPriority::class)->getTag('monolog.processor')); |
838 | 839 | } |
839 | 840 |
|
| 841 | + /** |
| 842 | + * @requires PHP 8.0 |
| 843 | + */ |
| 844 | + public function testWithLoggerChannelAutoconfiguration(): void |
| 845 | + { |
| 846 | + if (!class_exists(WithMonologChannel::class)) { |
| 847 | + $this->markTestSkipped('Monolog >= 3.5.0 is needed.'); |
| 848 | + } |
| 849 | + |
| 850 | + $container = $this->getContainer([], [ |
| 851 | + ServiceWithChannel::class => (new Definition(ServiceWithChannel::class))->setAutoconfigured(true), |
| 852 | + ]); |
| 853 | + |
| 854 | + $this->assertSame([ |
| 855 | + [ |
| 856 | + 'channel' => 'fixture', |
| 857 | + ], |
| 858 | + ], $container->getDefinition(ServiceWithChannel::class)->getTag('monolog.logger')); |
| 859 | + } |
| 860 | + |
840 | 861 | protected function getContainer(array $config = [], array $thirdPartyDefinitions = []): ContainerBuilder |
841 | 862 | { |
842 | 863 | $container = new ContainerBuilder(new EnvPlaceholderParameterBag()); |
|
0 commit comments