Small refactor to log_cmd