Chris@14: Chris@14: * Chris@14: * For the full copyright and license information, please view the LICENSE Chris@14: * file that was distributed with this source code. Chris@14: */ Chris@14: Chris@14: namespace Symfony\Component\HttpKernel\DependencyInjection; Chris@14: Chris@14: use Psr\Log\LoggerInterface; Chris@14: use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; Chris@14: use Symfony\Component\DependencyInjection\ContainerBuilder; Chris@17: use Symfony\Component\HttpKernel\Log\Logger; Chris@14: Chris@14: /** Chris@14: * Registers the default logger if necessary. Chris@14: * Chris@14: * @author Kévin Dunglas Chris@14: */ Chris@14: class LoggerPass implements CompilerPassInterface Chris@14: { Chris@14: /** Chris@14: * {@inheritdoc} Chris@14: */ Chris@14: public function process(ContainerBuilder $container) Chris@14: { Chris@14: $container->setAlias(LoggerInterface::class, 'logger') Chris@14: ->setPublic(false); Chris@14: Chris@14: if ($container->has('logger')) { Chris@14: return; Chris@14: } Chris@14: Chris@14: $container->register('logger', Logger::class) Chris@14: ->setPublic(false); Chris@14: } Chris@14: }