-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 SQL file logger #2911
Add SQL file logger #2911
Conversation
@BenMorel thanks for your contribution. The logger can indeed be useful but I think not everyone might need it, so maybe you could be offered as a separate package. You can create a small lib that depends on DBAL and provides that SQLLogger implementation. What do you think? |
I already have it in a repo, that I'm trying to tidy up and split into specific repositories. It's just that the FileLogger does not really belong anywhere and would probably end up in a repo of its own, which would be overkill IMO. Doctrine already ships with an EchoLogger, so I thought the FileLogger would belong there as well. |
I agree with @lcobucci. Only the interface belongs to the package itself. All implementations (including the existing ones) don't. Otherwise, we may end up implementing all possible loggers here. |
Probably better to generally use a PSR-3 logger?
Marco Pivetta
http://twitter.com/Ocramius
http://ocramius.github.com/
…On Sun, Nov 12, 2017 at 7:07 PM, Sergei Morozov ***@***.***> wrote:
I agree with @lcobucci <https://github.com/lcobucci>. Only the interface
belongs to the package itself. All implementations (including the existing
ones) don't. Otherwise, we may end up implementing all possible loggers
here.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2911 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAJakNhoMgjrFeLqtkZFMqf6BcgqjBe_ks5s1zP5gaJpZM4QWuIB>
.
|
Okay... I thought that basic implementations (the ones that don't require extra packages or extensions) did belong to this package. |
Quick implementation: <?php
namespace Svod\Infrastructure\Persistence\Doctrine;
use Doctrine\DBAL\Logging\SQLLogger;
use Psr\Log\LoggerInterface;
final class PsrSQLLogger implements SQLLogger
{
/**
* @var LoggerInterface
*/
private $logger;
public function __construct(LoggerInterface $logger)
{
$this->logger = $logger;
}
/**
* {@inheritDoc}
*/
public function startQuery($sql, array $params = null, array $types = null)
{
$this->logger->debug(
$sql,
compact('params', 'types')
);
}
/**
* {@inheritDoc}
*/
public function stopQuery()
{
}
} Works for me ™️ |
Additionally, deprecated `DebugStack` and `EchoSQLLogger` as per (my own) proposal in doctrine#2911 (comment)
Additionally, deprecated `DebugStack` and `EchoSQLLogger` as per (my own) proposal in doctrine#2911 (comment)
Additionally, deprecated `DebugStack` and `EchoSQLLogger` as per (my own) proposal in doctrine#2911 (comment)
Additionally, deprecated `DebugStack` and `EchoSQLLogger` as per (my own) proposal in doctrine#2911 (comment)
Additionally, deprecated `DebugStack` and `EchoSQLLogger` as per (my own) proposal in doctrine#2911 (comment)
Additionally, deprecated `EchoSQLLogger` as per proposal in doctrine#2911 (comment)
I've been using a SQL file logger for years, that proved very helpful during development, are you interested to merge it?
It produces an output similar to:
Note: ellipses are mine, the logger outputs the full query.
It writes a compact representation of parameters, representing objects as their class name along with their string representation if available, or their hash otherwise.