protected function startQueryLog()
{
$this->logFile = $this->tmpDir->getTempDir('logs') . '/query.log';
@unlink($this->logFile);
$this->connection->enableQueryLog();
$this->logger->pushHandler(new StreamHandler($this->logFile, LoggerEx::INFO));
$this->dispatcher->listen(QueryExecuted::class, function (QueryExecuted $query) {
$sql = preg_replace_callback('/\\?/', function () use($query, &$index) {
return sprintf("'%s'", $query->bindings[$index++ ?? 0]);
}, $query->sql);
$this->logger->info($sql);
});
}