refactor logging.