Add some logging to the query handling