-
-
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
Introduce logging middleware #4967
Introduce logging middleware #4967
Conversation
20f3a22
to
61d7adc
Compare
1754d89
to
52bb036
Compare
69a38c2
to
389dbe5
Compare
This case is already covered by `ConnectionTest::testExceptionOnPrepareAndExecute()`
src/Logging/Driver.php
Outdated
private function maskPassword(array $params): array | ||
{ | ||
if (isset($params['password'])) { | ||
$params['password'] = '******'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One might think we are giving an indication about the number of characters. How about this instead:
$params['password'] = '******'; | |
$params['password'] = '<redacted>'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I discussed this with my colleague and we came to the same conclusion. Let's change it.
24f43ac
to
8fcd454
Compare
Follow-up: doctrine/DoctrineBundle#1429 |
Hello @morozov |
@Igor100 here's an example: Lines 66 to 71 in 69a38c2
|
Hello. What's the recommended way of disabling sql logging for certain parts of the app? |
If you're using Monolog, you can try doing |
If SQLLogger is deprecated in 3.2, does that mean that it's safe to continue using in |
Yes. It means your code will break when upgrading to 4.0. |
From user perspective, deprecating the SQLLogger seems a bit weird to me as we are not able anymore to change it after the connection is created according to different contexts. Maybe you could provide a way to change or remove the logger in the connection decorator created by the middleware? |
The middleware is just an adapter between the DBAL driver and a PSR-3 logger. If the logger needs to implement any application-specific logic, it should be implemented in the logger. See #4967 (comment) for example. |
Hello @morozov ,
But then, how do you get the debugStack like the profiler does for exemple ? |
@nayodahl there's no equivalent of |
Closes #4941.
This middleware is meant to replace the
SQLLogger
interface but it's not a drop-in replacement:stopQuery()
method. If instrumentation around the query methods is needed, it should be implemented as a separate middleware.Technical details:
Test changes:
Connection::getWrappedConnection()
will return a driver connection while it may return a middleware (see Deprecate Connection::getWrappedConnection(), mark Connection::connect() internal #4966). The error handling duringprepare()
cannot always be tested in isolation and is covered in a more reliable way indbal/tests/Functional/ConnectionTest.php
Line 413 in 07453f2
testDeterminesDatabasePlatformWhenConnectingToNonExistentDatabase()
is removed since the middleware driver always implements theVersionAwarePlatformDriver
, even if the wrapped driver doesn't, so based on that, the wrapper connection will always connect to detect the server version. This will be likely addressed by Remove VersionAwarePlatformDriver and ServerInfoAwareConnection #4764 in 4.0.0. UPD: this entire feature is pointless (Remove VersionAwarePlatformDriver and ServerInfoAwareConnection #4764 (comment)).TODO:
ResultCacheTest
onDebugStack
(Refactor query caching tests #5008).