vendor/symfony/monolog-bundle/MonologBundle.php line 30

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Bundle\MonologBundle;
  11. use Monolog\Formatter\JsonFormatter;
  12. use Monolog\Formatter\LineFormatter;
  13. use Monolog\Handler\HandlerInterface;
  14. use Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\AddSwiftMailerTransportPass;
  15. use Symfony\Component\HttpKernel\Bundle\Bundle;
  16. use Symfony\Component\DependencyInjection\ContainerBuilder;
  17. use Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\LoggerChannelPass;
  18. use Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\DebugHandlerPass;
  19. use Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\AddProcessorsPass;
  20. use Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\FixEmptyLoggerPass;
  21. /**
  22. * Bundle.
  23. *
  24. * @author Jordi Boggiano <j.boggiano@seld.be>
  25. */
  26. class MonologBundle extends Bundle
  27. {
  28. public function build(ContainerBuilder $container)
  29. {
  30. parent::build($container);
  31. $container->addCompilerPass($channelPass = new LoggerChannelPass());
  32. if (!class_exists('Symfony\Bridge\Monolog\Processor\DebugProcessor') || !class_exists('Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddDebugLogProcessorPass')) {
  33. $container->addCompilerPass(new DebugHandlerPass($channelPass));
  34. }
  35. $container->addCompilerPass(new FixEmptyLoggerPass($channelPass));
  36. $container->addCompilerPass(new AddProcessorsPass());
  37. $container->addCompilerPass(new AddSwiftMailerTransportPass());
  38. }
  39. /**
  40. * @internal
  41. */
  42. public static function includeStacktraces(HandlerInterface $handler)
  43. {
  44. $formatter = $handler->getFormatter();
  45. if ($formatter instanceof LineFormatter || $formatter instanceof JsonFormatter) {
  46. $formatter->includeStacktraces();
  47. }
  48. }
  49. }