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

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <[email protected]>
  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\AddProcessorsPass;
  15. use Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\AddSwiftMailerTransportPass;
  16. use Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\FixEmptyLoggerPass;
  17. use Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\LoggerChannelPass;
  18. use Symfony\Component\DependencyInjection\ContainerBuilder;
  19. use Symfony\Component\HttpKernel\Bundle\Bundle;
  20. /**
  21. * @author Jordi Boggiano <[email protected]>
  22. *
  23. * @final since 3.9.0
  24. */
  25. class MonologBundle extends Bundle
  26. {
  27. /**
  28. * @return void
  29. */
  30. public function build(ContainerBuilder $container)
  31. {
  32. parent::build($container);
  33. $container->addCompilerPass($channelPass = new LoggerChannelPass());
  34. $container->addCompilerPass(new FixEmptyLoggerPass($channelPass));
  35. $container->addCompilerPass(new AddProcessorsPass());
  36. $container->addCompilerPass(new AddSwiftMailerTransportPass());
  37. }
  38. /**
  39. * @internal
  40. *
  41. * @return void
  42. */
  43. public static function includeStacktraces(HandlerInterface $handler)
  44. {
  45. $formatter = $handler->getFormatter();
  46. if ($formatter instanceof LineFormatter || $formatter instanceof JsonFormatter) {
  47. $formatter->includeStacktraces();
  48. }
  49. }
  50. }