Refactor write logs to temp