-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace
DebugStack
used for logging (#57)
`DebugStack` has been deprecated in DBAL 3.2 and will be removed in DBAL 4.
- Loading branch information
Showing
6 changed files
with
53 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Webfactory\Doctrine\ORMTestInfrastructure; | ||
|
||
use Psr\Log\AbstractLogger; | ||
use Psr\Log\LoggerInterface; | ||
|
||
class QueryLogger extends AbstractLogger | ||
{ | ||
public bool $enabled = true; | ||
private array $queries = []; | ||
|
||
public function log($level, \Stringable|string $message, array $context = []): void | ||
{ | ||
if (!$this->enabled) { | ||
return; | ||
} | ||
|
||
if (str_starts_with($message, 'Executing')) { | ||
$this->queries[] = new Query($context['sql'], $context['params'] ?? []); | ||
} else if ('Beginning transaction' === $message) { | ||
$this->queries[] = new Query('"START TRANSACTION"', []); | ||
} else if ('Committing transaction' === $message) { | ||
$this->queries[] = new Query('"COMMIT"', []); | ||
} else if ('Rolling back transaction' === $message) { | ||
$this->queries[] = new Query('"ROLLBACK"', []); | ||
} | ||
} | ||
|
||
public function getQueries() | ||
{ | ||
return $this->queries; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
use Symfony\Component\ErrorHandler\Debug; | ||
use Symfony\Component\ErrorHandler\DebugClassLoader; | ||
|
||
require_once __DIR__.'/../vendor/autoload.php'; | ||
|
||
DebugClassLoader::enable(); |