Add log_errors option, related logic and tests