vendor/symfony/monolog-bridge/Logger.php line 23

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\Bridge\Monolog;
  11. use Monolog\Logger as BaseLogger;
  12. use Monolog\ResettableInterface;
  13. use Symfony\Component\HttpFoundation\Request;
  14. use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
  15. use Symfony\Contracts\Service\ResetInterface;
  16. /**
  17.  * @author Fabien Potencier <fabien@symfony.com>
  18.  */
  19. class Logger extends BaseLogger implements DebugLoggerInterfaceResetInterface
  20. {
  21.     /**
  22.      * {@inheritdoc}
  23.      *
  24.      * @param Request|null $request
  25.      */
  26.     public function getLogs(/* Request $request = null */)
  27.     {
  28.         if (\func_num_args() < && __CLASS__ !== static::class && __CLASS__ !== (new \ReflectionMethod($this__FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface && !$this instanceof \Mockery\MockInterface) {
  29.             @trigger_error(sprintf('The "%s()" method will have a new "Request $request = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2.'__METHOD__), \E_USER_DEPRECATED);
  30.         }
  31.         if ($logger $this->getDebugLogger()) {
  32.             return $logger->getLogs(...\func_get_args());
  33.         }
  34.         return [];
  35.     }
  36.     /**
  37.      * {@inheritdoc}
  38.      *
  39.      * @param Request|null $request
  40.      */
  41.     public function countErrors(/* Request $request = null */)
  42.     {
  43.         if (\func_num_args() < && __CLASS__ !== static::class && __CLASS__ !== (new \ReflectionMethod($this__FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface && !$this instanceof \Mockery\MockInterface) {
  44.             @trigger_error(sprintf('The "%s()" method will have a new "Request $request = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2.'__METHOD__), \E_USER_DEPRECATED);
  45.         }
  46.         if ($logger $this->getDebugLogger()) {
  47.             return $logger->countErrors(...\func_get_args());
  48.         }
  49.         return 0;
  50.     }
  51.     /**
  52.      * {@inheritdoc}
  53.      */
  54.     public function clear()
  55.     {
  56.         if ($logger $this->getDebugLogger()) {
  57.             $logger->clear();
  58.         }
  59.     }
  60.     /**
  61.      * {@inheritdoc}
  62.      */
  63.     public function reset()
  64.     {
  65.         $this->clear();
  66.         if ($this instanceof ResettableInterface) {
  67.             parent::reset();
  68.         }
  69.     }
  70.     public function removeDebugLogger()
  71.     {
  72.         foreach ($this->processors as $k => $processor) {
  73.             if ($processor instanceof DebugLoggerInterface) {
  74.                 unset($this->processors[$k]);
  75.             }
  76.         }
  77.         foreach ($this->handlers as $k => $handler) {
  78.             if ($handler instanceof DebugLoggerInterface) {
  79.                 unset($this->handlers[$k]);
  80.             }
  81.         }
  82.     }
  83.     /**
  84.      * Returns a DebugLoggerInterface instance if one is registered with this logger.
  85.      */
  86.     private function getDebugLogger(): ?DebugLoggerInterface
  87.     {
  88.         foreach ($this->processors as $processor) {
  89.             if ($processor instanceof DebugLoggerInterface) {
  90.                 return $processor;
  91.             }
  92.         }
  93.         foreach ($this->handlers as $handler) {
  94.             if ($handler instanceof DebugLoggerInterface) {
  95.                 return $handler;
  96.             }
  97.         }
  98.         return null;
  99.     }
  100. }