make QueryCounter logging logic injectable

- add interface and default implementation for logging
- refactored to remove duplicated code
close #6