"""
    Log task state.
    :param task_instance: the task instance
    :param lead_msg: lead message
    :meta private:
    """
    params = [
        lead_msg,
        str(task_instance.state).upper(),
        task_instance.dag_id,
        task_instance.task_id,
    ]
    message = "%sMarking task as %s. dag_id=%s, task_id=%s, "
    if task_instance.map_index >= 0:
        params.append(task_instance.map_index)
        message += "map_index=%d, "
    log.info(
        message + "execution_date=%s, start_date=%s, end_date=%s",
        *params,
        _date_or_empty(task_instance=task_instance, attr="execution_date"),
        _date_or_empty(task_instance=task_instance, attr="start_date"),
        _date_or_empty(task_instance=task_instance, attr="end_date"),
    )
def _date_or_empty(*, task_instance: TaskInstance | TaskInstancePydantic, attr: str) -> str: