code: def _build_event_file_logger(source: Event.SourceType, sink_dir: str):
      logger = logging.getLogger("_ray_event_logger")
      logger.setLevel(logging.INFO)
      dir_path = pathlib.Path(sink_dir) / "events"
      filepath = dir_path / f"event_{source}.log"
      dir_path.mkdir(exist_ok=True)
      filepath.touch(exist_ok=True)
      # Configure the logger.
      handler = logging.FileHandler(filepath)
      formatter = logging.Formatter("%(message)s")
      handler.setFormatter(formatter)
      logger.addHandler(handler)
      logger.propagate = False
      return logger
  
imports: import logging
  import pathlib
  import json
  import random
  import string
  import socket
  import os
  import threading
  from typing import Dict, Optional
  from datetime import datetime
  from google.protobuf.json_format import MessageToDict, Parse
  from ray.core.generated.event_pb2 import Event
label_desc: Use image node_id 2 for calling a global function with example usage: _build_event_file_logger(source, sink_dir) and returns: logger