code: def add_log(execdate, session, dag_maker, timezone_override=None):
      with dag_maker(
          dag_id="logging", default_args={"start_date": execdate}
      ):
          task = EmptyOperator(task_id="dummy")
      dag_maker.create_dagrun()
      task_instance = TaskInstance(
          task=task, execution_date=execdate, state="success"
      )
      session.merge(task_instance)
      log = Log(State.RUNNING, task_instance)
      if timezone_override:
          log.dttm = log.dttm.astimezone(timezone_override)
      session.add(log)
      session.commit()
      return log
  
file_path: airflow/tests/models/test_timestamp.py
imports: from __future__ import annotations
  import pendulum
  import pytest
  import time_machine
  from airflow.models import Log, TaskInstance
  from airflow.operators.empty import EmptyOperator
  from airflow.utils import timezone
  from airflow.utils.session import provide_session
  from airflow.utils.state import State
  from tests.test_utils.db import clear_db_dags, clear_db_logs, clear_db_runs
label_desc: Use image node_id 2 for calling a global function with example usage: add_log(execdate, session, dag_maker, timezone_override) and returns: log