code: def configure_logging(
      log_fname: str, log_level: int, run_id: Optional[str] = None
  ) -> None:
      # TODO: we may want make prints and stdout make it into the logs
      # sys.stdout = open(settings.log_internal, "a")
      # sys.stderr = open(settings.log_internal, "a")
      log_handler = logging.FileHandler(log_fname)
      log_handler.setLevel(log_level)
  
      class WBFilter(logging.Filter):
          def filter(self, record: "Any") -> bool:
              record.run_id = run_id
              return True
  
      if run_id:
          formatter = logging.Formatter(
              "%(asctime)s %(levelname)-7s %(threadName)-10s:%(process)d "
              "[%(run_id)s:%(filename)s:%(funcName)s():%(lineno)s] %(message)s"
          )
      else:
          formatter = logging.Formatter(
              "%(asctime)s %(levelname)-7s %(threadName)-10s:%(process)d "
              "[%(filename)s:%(funcName)s():%(lineno)s] %(message)s"
          )
  
      log_handler.setFormatter(formatter)
      if run_id:
          log_handler.addFilter(WBFilter())
      # If this is called without "wandb", backend logs from this module
      # are not streamed to `debug-internal.log` when we spawn with fork
      # TODO: (cvp) we should really take another pass at logging in general
      root = logging.getLogger("wandb")
      root.propagate = False
      root.setLevel(logging.DEBUG)
      root.addHandler(log_handler)
  
imports: import atexit
  import logging
  import os
  import queue
  import sys
  import threading
  import time
  import traceback
  from datetime import datetime
  from typing import TYPE_CHECKING, Any, List, Optional
  import psutil
  import wandb
  from ..interface.interface_queue import InterfaceQueue
  from ..lib import tracelog
  from .None import context, handler, internal_util, sender, writer
label_desc: Use image node_id 3 for calling a global function with example usage: configure_logging(log_fname, log_level, run_id) and returns: True