docstr: Adapter for the Python logger that's used to emit events.
  
  When events are emitted, they are aggregated and available via
  state API and dashboard.
  
  This class is thread-safe.
docstr_tok: ["Adapter","for","the","Python","logger","that","'s","used","to","emit","events",".","When","events","are","emitted",",","they","are","aggregated","and","available","via","state","API","and","dashboard",".","This","class","is","thread-safe","."]
code: def __init__(self, source: Event.SourceType, logger: logging.Logger):
      """Adapter for the Python logger that's used to emit events.
  
      When events are emitted, they are aggregated and available via
      state API and dashboard.
  
      This class is thread-safe.
      """
      self.logger = logger
      # Aligned with `event.proto`'s `message Event``
      self.source = source
      self.source_hostname = socket.gethostname()
      self.source_pid = os.getpid()
  
      # The below fields must be protected by this lock.
      self.lock = threading.Lock()
      # {str -> str} typed dict
      self.global_context = {}
  
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 1 to create a new EventLoggerAdapter object  with example: obj = EventLoggerAdapter(source, logger)