BacktraceLogger.php 671 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace Doctrine\Bundle\DoctrineBundle\Dbal\Logging;
  3. use Doctrine\DBAL\Logging\DebugStack;
  4. use function array_shift;
  5. use function debug_backtrace;
  6. use const DEBUG_BACKTRACE_IGNORE_ARGS;
  7. final class BacktraceLogger extends DebugStack
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function startQuery($sql, ?array $params = null, ?array $types = null): void
  13. {
  14. parent::startQuery($sql, $params, $types);
  15. $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
  16. // skip first since it's always the current method
  17. array_shift($backtrace);
  18. $this->queries[$this->currentQuery]['backtrace'] = $backtrace;
  19. }
  20. }