move logic that creates the SQL query into LogQueryBuilder class