Better query logging