Logger.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien.potencier@symfony-project.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\Logger;
  11. use Monolog\Logger as BaseLogger;
  12. use Symfony\Component\HttpKernel\Log\LoggerInterface;
  13. use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
  14. /**
  15. * Logger.
  16. *
  17. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  18. */
  19. class Logger extends BaseLogger implements LoggerInterface
  20. {
  21. /**
  22. * Returns a DebugLoggerInterface instance if one is registered with this logger.
  23. *
  24. * @return DebugLoggerInterface A DebugLoggerInterface instance or null if none is registered
  25. */
  26. public function getDebugLogger()
  27. {
  28. $handler = $this->handler;
  29. while ($handler) {
  30. if ($handler instanceof DebugLoggerInterface) {
  31. return $handler;
  32. }
  33. $handler = $handler->getParent();
  34. }
  35. return null;
  36. }
  37. public function log($message, $level)
  38. {
  39. return $this->addMessage($level, $message);
  40. }
  41. }