Connection.php
2 years ago
DebugStack.php
2 years ago
Driver.php
2 years ago
LoggerChain.php
2 years ago
Middleware.php
2 years ago
SQLLogger.php
2 years ago
Statement.php
2 years ago
index.php
2 years ago
Connection.php
52 lines
| 1 | <?php |
| 2 | declare (strict_types=1); |
| 3 | namespace MailPoetVendor\Doctrine\DBAL\Logging; |
| 4 | if (!defined('ABSPATH')) exit; |
| 5 | use MailPoetVendor\Doctrine\DBAL\Driver\Connection as ConnectionInterface; |
| 6 | use MailPoetVendor\Doctrine\DBAL\Driver\Middleware\AbstractConnectionMiddleware; |
| 7 | use MailPoetVendor\Doctrine\DBAL\Driver\Result; |
| 8 | use MailPoetVendor\Doctrine\DBAL\Driver\Statement as DriverStatement; |
| 9 | use MailPoetVendor\Psr\Log\LoggerInterface; |
| 10 | final class Connection extends AbstractConnectionMiddleware |
| 11 | { |
| 12 | private LoggerInterface $logger; |
| 13 | public function __construct(ConnectionInterface $connection, LoggerInterface $logger) |
| 14 | { |
| 15 | parent::__construct($connection); |
| 16 | $this->logger = $logger; |
| 17 | } |
| 18 | public function __destruct() |
| 19 | { |
| 20 | $this->logger->info('Disconnecting'); |
| 21 | } |
| 22 | public function prepare(string $sql) : DriverStatement |
| 23 | { |
| 24 | return new Statement(parent::prepare($sql), $this->logger, $sql); |
| 25 | } |
| 26 | public function query(string $sql) : Result |
| 27 | { |
| 28 | $this->logger->debug('Executing query: {sql}', ['sql' => $sql]); |
| 29 | return parent::query($sql); |
| 30 | } |
| 31 | public function exec(string $sql) : int |
| 32 | { |
| 33 | $this->logger->debug('Executing statement: {sql}', ['sql' => $sql]); |
| 34 | return parent::exec($sql); |
| 35 | } |
| 36 | public function beginTransaction() |
| 37 | { |
| 38 | $this->logger->debug('Beginning transaction'); |
| 39 | return parent::beginTransaction(); |
| 40 | } |
| 41 | public function commit() |
| 42 | { |
| 43 | $this->logger->debug('Committing transaction'); |
| 44 | return parent::commit(); |
| 45 | } |
| 46 | public function rollBack() |
| 47 | { |
| 48 | $this->logger->debug('Rolling back transaction'); |
| 49 | return parent::rollBack(); |
| 50 | } |
| 51 | } |
| 52 |