add optional query logging

@grncdr per our discussion.