Logging cursor factory for SQLite