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

Introduced a PSR-3 logger adapter #3156

Closed
wants to merge 1 commit into from

Conversation

morozov
Copy link
Member

@morozov morozov commented May 21, 2018

  1. Introduced a PSR-3 logger adapter as per Add SQL file logger #2911 (comment).
  2. Deprecated EchoSQLLogger as per Add SQL file logger #2911 (comment).
Q A
Type improvement
BC Break no
Fixed issues none

@morozov
Copy link
Member Author

morozov commented May 21, 2018

The coding standards failure is expected due to the non-compliant signature of SQLLogger::startQuery().

Additionally, deprecated `EchoSQLLogger` as per proposal in doctrine#2911 (comment)
/** @var LoggerInterface */
private $logger;

public function __construct(LoggerInterface $logger)
Copy link
Member

Choose a reason for hiding this comment

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

This requires an addition to composer.json

Copy link
Member Author

Choose a reason for hiding this comment

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

It’s not a hard requirement. Do you want to add a suggestion?

Copy link
Member

Choose a reason for hiding this comment

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

Would need to be a hard requirement if we rely on its signature in any way.

Copy link
Member Author

Choose a reason for hiding this comment

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

We rely on this signature in the same way as on signatures of PDO, mysqli and other extensions, all of which are optional.

Looks like we have different expectations from PSR-3 in DBAL. As I see it, it will just enable dumping debug information into an abstract channel as requested in #2911. We're not deprecating SQLLogger which has a more specific interface oriented on query execution, not just messages. Therefore, no need to introduce a hard dependency on PSR-3.

use Psr\Log\LoggerInterface;

/**
* Logs every query as a debug message
Copy link
Member

Choose a reason for hiding this comment

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

Probably no longer true

Copy link
Member Author

Choose a reason for hiding this comment

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

Why?

/**
* Logs every query as a debug message
*/
final class PsrAdapter implements SQLLogger
Copy link
Member

Choose a reason for hiding this comment

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

Rather than PsrAdapter, PsrLoggerSqlLogger? PsrSqlLogger?

Copy link
Member Author

@morozov morozov May 25, 2018

Choose a reason for hiding this comment

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

I think the "adapter" here is essential since unlike other implementations, this class just converts calls from one API to another. While the SQL part is implied since the DBAL doesn't log anything else than SQL.

* {@inheritDoc}
*/
public function stopQuery()
{
Copy link
Member

Choose a reason for hiding this comment

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

We probably want to log stopQuery as debug too.

Copy link
Member Author

Choose a reason for hiding this comment

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

This way we’ll have two almost identical consecutive messages per query. Without precise timestamps it will be just a noise. Want to elaborate?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, but the start/end are vital to profile queries. Filtering them out would be trivial here, while adding them wouldn't be as easy.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think, using a logging interface for profiling is an abuse. SQLLogger suits this need better.

@morozov
Copy link
Member Author

morozov commented May 25, 2018

Linking this to #719.

@morozov morozov modified the milestones: 2.8.0, 2.9.0 Jun 19, 2018
@morozov morozov closed this Oct 2, 2018
@morozov morozov removed this from the 2.9.0 milestone Oct 4, 2018
@morozov morozov deleted the psr-adapter branch October 13, 2018 01:04
@ragboyjr
Copy link

ragboyjr commented Apr 3, 2020

@morozov curious, why was this closed?

@morozov
Copy link
Member Author

morozov commented Apr 3, 2020

@ragboyjr because it's not clear how to proceed and the DBAL's logger is not really a logger: #3513 (comment).

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants