log_run() modified to return the output