code: def log_to_file(logger, log_dir, log_filename="log.txt"):
      if os.path.isdir(log_dir):
          handler = logging.FileHandler(
              os.path.join(log_dir, log_filename)
          )
      else:
          handler = logging.FileHandler(log_dir)
  
      formatter = logging.Formatter(
          fmt="[%(levelname)s] %(asctime)s [%(filename)12s:%(lineno)5d]:\t%(message)s"
      )
      handler.setFormatter(formatter)
  
      logger.addHandler(handler)
  
imports: import sys
  import os
  import logging
label_desc: Use image node_id 2 for calling a global function with example usage: log_to_file(logger, log_dir, log_filename) without return types