adds query logging