Ecodev /
felix
| 1 | <?php |
||||
| 2 | |||||
| 3 | declare(strict_types=1); |
||||
| 4 | |||||
| 5 | namespace Ecodev\Felix\DBAL\Logging; |
||||
| 6 | |||||
| 7 | use Doctrine\DBAL\Logging\DebugStack; |
||||
| 8 | use Doctrine\DBAL\Logging\SQLLogger; |
||||
| 9 | |||||
| 10 | /** |
||||
| 11 | * A SQL logger that forward logs to Laminas Log. |
||||
| 12 | */ |
||||
| 13 | final class ForwardSQLLogger extends DebugStack implements SQLLogger |
||||
|
0 ignored issues
–
show
The class
Doctrine\DBAL\Logging\DebugStack has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 14 | { |
||||
| 15 | public function stopQuery(): void |
||||
| 16 | { |
||||
| 17 | if ($this->enabled) { |
||||
| 18 | parent::stopQuery(); |
||||
| 19 | |||||
| 20 | $this->forwardLog($this->queries[$this->currentQuery]); |
||||
| 21 | } |
||||
| 22 | } |
||||
| 23 | |||||
| 24 | /** |
||||
| 25 | * Forward query to file logger. |
||||
| 26 | */ |
||||
| 27 | private function forwardLog(array $query): void |
||||
| 28 | { |
||||
| 29 | $extra = [ |
||||
| 30 | 'params' => $query['params'], |
||||
| 31 | 'time' => number_format($query['executionMS'], 6), |
||||
| 32 | ]; |
||||
| 33 | |||||
| 34 | // Here we cannot inject the logger via DI, or it would be created too early and |
||||
| 35 | // break unit tests by creating two parallel connection to DB and thus timeout |
||||
| 36 | // when a tests's transaction is pending but a log is trying to be written on the other connection |
||||
| 37 | _log()->debug($query['sql'], $extra); |
||||
| 38 | } |
||||
| 39 | } |
||||
| 40 |
This interface has been deprecated. The supplier of the interface has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the interface will be removed and what other interface to use instead.