[dbal] refactor SQL logging for tests