Skip to content

Commit 2a1e9d6

Browse files
committed
Diag: override driver's logger after construction
1 parent 1a231bc commit 2a1e9d6

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

.github/workflows/phpunit-tests-doltlite.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,13 @@ jobs:
184184
$pdo_class = PHP_VERSION_ID >= 80400 ? PDO\SQLite::class : PDO::class;
185185
$pdo = new $pdo_class("sqlite::memory:");
186186
$conn = new WP_SQLite_Connection(["pdo" => $pdo]);
187-
// Wrap the logger to print every query live so we see where it crashes.
188-
$conn->set_query_logger(function (string $sql, array $params) use ($pdo) {
189-
$short = substr(str_replace("\n", " ", preg_replace("/\s+/", " ", trim($sql))), 0, 200);
190-
fwrite(STDERR, sprintf("[SQL] %s\n", $short));
191-
});
192187
$driver = new WP_SQLite_Driver($conn, "wp");
188+
// The driver replaces the logger in its constructor; set a new one
189+
// that prints every query live so we see where it crashes.
190+
$conn->set_query_logger(function (string $sql, array $params) {
191+
$short = substr(str_replace("\n", " ", preg_replace("/\s+/", " ", trim($sql))), 0, 250);
192+
fwrite(STDOUT, sprintf("[SQL] %s\n", $short));
193+
});
193194
194195
$driver->query("CREATE TABLE t (a INT)");
195196
echo "== running ALTER TABLE t ADD b INT, DROP a ==\n";

0 commit comments

Comments
 (0)