code: def log_app(backup_modules, log_path):
      @dont_initialize_flask_app_submodules(
          skip_all_except=[
              "init_appbuilder",
              "init_jinja_globals",
              "init_appbuilder_views",
              "init_api_connexion",
          ]
      )
      @conf_vars(
          {
              (
                  "logging",
                  "logging_config_class",
              ): "airflow_local_settings.LOGGING_CONFIG",
              ("fab", "auth_rate_limited"): "False",
          }
      )
      def factory():
          app = create_app(testing=True)
          app.config["WTF_CSRF_ENABLED"] = False
          settings.configure_orm()
          security_manager = app.appbuilder.sm
          if not security_manager.find_user(username="test"):
              security_manager.add_user(
                  username="test",
                  first_name="test",
                  last_name="test",
                  email="test@fab.org",
                  role=security_manager.find_role("Admin"),
                  password="test",
              )
          return app
  
      # Create a custom logging configuration
      logging_config = copy.deepcopy(DEFAULT_LOGGING_CONFIG)
      logging_config["handlers"]["task"]["base_log_folder"] = str(
          log_path
      )
  
      with tempfile.TemporaryDirectory() as settings_dir:
          local_settings = pathlib.Path(
              settings_dir, "airflow_local_settings.py"
          )
          local_settings.write_text(
              f"LOGGING_CONFIG = {logging_config!r}"
          )
          sys.path.append(settings_dir)
          yield factory()
          sys.path.remove(settings_dir)
  
      logging.config.dictConfig(DEFAULT_LOGGING_CONFIG)
  
imports: from __future__ import annotations
  import copy
  import logging
  import logging.config
  import pathlib
  import shutil
  import sys
  import tempfile
  import unittest.mock
  import urllib.parse
  import pytest
  from airflow import settings
  from airflow.config_templates.airflow_local_settings import DEFAULT_LOGGING_CONFIG
  from airflow.models import DagBag, DagRun
  from airflow.models.tasklog import LogTemplate
  from airflow.utils import timezone
  from airflow.utils.log.file_task_handler import FileTaskHandler
  from airflow.utils.log.logging_mixin import ExternalLoggingMixin
  from airflow.utils.session import create_session
  from airflow.utils.state import DagRunState, TaskInstanceState
  from airflow.utils.types import DagRunType
  from airflow.www.app import create_app
  from tests.test_utils.config import conf_vars
  from tests.test_utils.db import clear_db_dags, clear_db_runs
  from tests.test_utils.decorators import dont_initialize_flask_app_submodules
  from tests.test_utils.www import client_with_login
label_desc: Use image node_id 3 for calling a global function with example usage: log_app(backup_modules, log_path) and returns: app