summaryrefslogtreecommitdiff
path: root/vendor/doctrine/dbal/src/Logging/Driver.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/doctrine/dbal/src/Logging/Driver.php')
-rw-r--r--vendor/doctrine/dbal/src/Logging/Driver.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/vendor/doctrine/dbal/src/Logging/Driver.php b/vendor/doctrine/dbal/src/Logging/Driver.php
new file mode 100644
index 0000000..35acd39
--- /dev/null
+++ b/vendor/doctrine/dbal/src/Logging/Driver.php
@@ -0,0 +1,50 @@
1<?php
2
3declare(strict_types=1);
4
5namespace Doctrine\DBAL\Logging;
6
7use Doctrine\DBAL\Driver as DriverInterface;
8use Doctrine\DBAL\Driver\Middleware\AbstractDriverMiddleware;
9use Psr\Log\LoggerInterface;
10use SensitiveParameter;
11
12final class Driver extends AbstractDriverMiddleware
13{
14 /** @internal This driver can be only instantiated by its middleware. */
15 public function __construct(DriverInterface $driver, private readonly LoggerInterface $logger)
16 {
17 parent::__construct($driver);
18 }
19
20 /**
21 * {@inheritDoc}
22 */
23 public function connect(
24 #[SensitiveParameter]
25 array $params,
26 ): Connection {
27 $this->logger->info('Connecting with parameters {params}', ['params' => $this->maskPassword($params)]);
28
29 return new Connection(
30 parent::connect($params),
31 $this->logger,
32 );
33 }
34
35 /**
36 * @param array<string,mixed> $params Connection parameters
37 *
38 * @return array<string,mixed>
39 */
40 private function maskPassword(
41 #[SensitiveParameter]
42 array $params,
43 ): array {
44 if (isset($params['password'])) {
45 $params['password'] = '<redacted>';
46 }
47
48 return $params;
49 }
50}