code: def build_logger(logger_name, logger_filename):
      global handler
  
      formatter = logging.Formatter(
          fmt="%(asctime)s | %(levelname)s | %(name)s | %(message)s",
          datefmt="%Y-%m-%d %H:%M:%S",
      )
  
      # Set the format of root handlers
      if not logging.getLogger().handlers:
          logging.basicConfig(level=logging.INFO)
      logging.getLogger().handlers[0].setFormatter(formatter)
  
      # Redirect stdout and stderr to loggers
      stdout_logger = logging.getLogger("stdout")
      stdout_logger.setLevel(logging.INFO)
      sl = StreamToLogger(stdout_logger, logging.INFO)
      sys.stdout = sl
  
      stderr_logger = logging.getLogger("stderr")
      stderr_logger.setLevel(logging.ERROR)
      sl = StreamToLogger(stderr_logger, logging.ERROR)
      sys.stderr = sl
  
      # Get logger
      logger = logging.getLogger(logger_name)
      logger.setLevel(logging.INFO)
  
      # Add a file handler for all loggers
      if handler is None:
          os.makedirs(LOGDIR, exist_ok=True)
          filename = os.path.join(LOGDIR, logger_filename)
          handler = logging.handlers.TimedRotatingFileHandler(
              filename, when="D", utc=True
          )
          handler.setFormatter(formatter)
  
          for name, item in logging.root.manager.loggerDict.items():
              if isinstance(item, logging.Logger):
                  item.addHandler(handler)
  
      return logger
  
file_path: llmga/llmga/llava/utils.py
imports: import datetime
  import logging
  import logging.handlers
  import os
  import sys
  import requests
  from llmga.llava.constants import LOGDIR
label_desc: Use image node_id 1 for calling a global function with example usage: build_logger(logger_name, logger_filename) and returns: logger