ENH: finished up query and connection logging