def _log(
      self,
      log: list[Mapping[str, Any]],
      steps: int,
      entity_key: str,
      entity_log: Mapping[str, Any],
      game_master_key: str,
      game_master_log: Mapping[str, Any],
  ):
    """Modify log in place to append a new entry."""
    game_master_finalized_log = {}
    for segment_key, segment_log in game_master_log.items():
      game_master_finalized_log[segment_key] = {}
      for component_key, component_value in segment_log.items():
        if component_value:
          tmp_log_dict = {
              key: value for key, value in component_value.items() if value
          }
          if len(tmp_log_dict) > 1:
            # Only log if component logged more than just a key.
            game_master_finalized_log[segment_key][component_key] = tmp_log_dict

    log.append({
        'Step': steps,
        entity_key: entity_log,
        game_master_key: game_master_finalized_log,
        'Summary': f'Step {steps} {game_master_key}',
    })
Modify log in place to append a new entry.
concordia/environment/engines/sequential.py