code: def initialize_logging(cfg: Optional[Any] = None, actual_logger=None):
      format = "%(asctime)s - %(levelname)s: %(message)s"
  
      if actual_logger is None:
          actual_logger = logging.root
          logging.getLogger("sqlitedict").setLevel(logging.ERROR)
      else:
          actual_logger.handlers.clear()
  
      actual_logger.setLevel(logging.INFO)
      console_handler = logging.StreamHandler()
      formatter = logging.Formatter(format)
      console_handler.setFormatter(formatter)
      console_handler.addFilter(IgnorePatchRequestsFilter())
      actual_logger.addHandler(console_handler)
  
      if cfg is not None:
          logs_dir = f"{cfg.output_directory}/"
          os.makedirs(logs_dir, exist_ok=True)
          file_handler = logging.FileHandler(
              filename=f"{logs_dir}/logs.log"
          )
          file_formatter = logging.Formatter(format)
          file_handler.setFormatter(file_formatter)
          actual_logger.addHandler(file_handler)
  
file_path: h2o-llmstudio/llm_studio/src/utils/logging_utils.py
imports: import io
  import json
  import logging
  import os
  import re
  from typing import Any, Optional
  from llm_studio.src.utils.plot_utils import PlotData
label_desc: Use image node_id 1 for calling a global function with example usage: initialize_logging(cfg, actual_logger) without return types