4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\HttpKernel\EventListener;
14 @trigger_error('The '.__NAMESPACE__.'\ErrorsLoggerListener class is deprecated since version 2.6 and will be removed in 3.0. Use the Symfony\Component\HttpKernel\EventListener\DebugHandlersListener class instead.', E_USER_DEPRECATED);
16 use Psr\Log\LoggerInterface;
17 use Symfony\Component\Debug\ErrorHandler;
18 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
19 use Symfony\Component\HttpKernel\KernelEvents;
22 * Injects the logger into the ErrorHandler, so that it can log various errors.
24 * @author Colin Frei <colin@colinfrei.com>
25 * @author Konstantin Myakshin <koc-dp@yandex.ru>
27 * @deprecated since version 2.6, to be removed in 3.0. Use the DebugHandlersListener class instead.
29 class ErrorsLoggerListener implements EventSubscriberInterface
34 public function __construct($channel, LoggerInterface $logger = null)
36 $this->channel = $channel;
37 $this->logger = $logger;
40 public function injectLogger()
42 if (null !== $this->logger) {
43 ErrorHandler::setLogger($this->logger, $this->channel);
48 public static function getSubscribedEvents()
50 return array(KernelEvents::REQUEST => array('injectLogger', 2048));