Log sql before executing query, fixes #200