Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add query backtrace logger #3513

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions lib/Doctrine/DBAL/Logging/BacktraceLogger.php
@@ -0,0 +1,24 @@
<?php

namespace Doctrine\DBAL\Logging;

class BacktraceLogger extends DebugStack
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd avoid coupling the BacktraceLogger to the existing DebugStack one, if possible

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, the whole point here is to add the backtrace into the data stored for each query. Not coupling it would defeat the point.

{
/**
* {@inheritdoc}
*/
public function startQuery($sql, ?array $params = null, ?array $types = null)
{
parent::startQuery($sql, $params, $types);

$this->queries[$this->currentQuery]['backtrace'] = array_reverse(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS));
alcaeus marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* {@inheritdoc}
*/
public function stopQuery()
{
parent::stopQuery();
alcaeus marked this conversation as resolved.
Show resolved Hide resolved
}
}