refactor log thread