LoggerChain.php 769 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace Doctrine\DBAL\Logging;
  3. /**
  4. * Chains multiple SQLLogger.
  5. */
  6. class LoggerChain implements SQLLogger
  7. {
  8. /** @var SQLLogger[] */
  9. private $loggers = [];
  10. /**
  11. * Adds a logger in the chain.
  12. *
  13. * @return void
  14. */
  15. public function addLogger(SQLLogger $logger)
  16. {
  17. $this->loggers[] = $logger;
  18. }
  19. /**
  20. * {@inheritdoc}
  21. */
  22. public function startQuery($sql, ?array $params = null, ?array $types = null)
  23. {
  24. foreach ($this->loggers as $logger) {
  25. $logger->startQuery($sql, $params, $types);
  26. }
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function stopQuery()
  32. {
  33. foreach ($this->loggers as $logger) {
  34. $logger->stopQuery();
  35. }
  36. }
  37. }