code: def build_file_handler(
      filepath: str,
      level: int = DEFAULT_LOG_LEVEL
      # pyre-fixme[24]: Generic type `logging.StreamHandler` expects 1 type parameter.
  ) -> logging.StreamHandler:
      """Build a file handle that logs entries to the given file, using the
      same formatting as the stream handler.
  
      Args:
          filepath: Location of the file to log output to. If the file exists, output
              will be appended. If it does not exist, a new file will be created.
          level: The log level. By default, sets level to INFO
  
      Returns:
          A logging.FileHandler instance
      """
      if os.path.isfile(filepath):
          get_logger(__name__).warning(
              f"Log file ({filepath}) already exists, appending logs."
          )
      logfile = logging.FileHandler(filepath)
      logfile.setLevel(level=level)
      formatter = _build_stream_formatter()
      logfile.setFormatter(formatter)
      return logfile
  
imports: import logging
  import os
  import re
  from functools import wraps
  from typing import Any, Callable, Iterable, List, TypeVar
  from ax.utils.common.decorator import ClassDecorator
label_desc: Use image node_id 3 for calling a global function with example usage: build_file_handler(filepath, level) and returns: logfile