code: def _push_log_events_to_read_queue_callback(
      component_name: str, read_queue: queue.PriorityQueue
  ):
      """Pushes _LogEvents from websocket to read_queue.
  
      Returns callback function used with `on_message_callback` of websocket.WebSocketApp.
  
      """
  
      def callback(ws_app: WebSocketApp, msg: str):
          # We strongly trust that the contract on API will hold atm :D
          event_dict = json.loads(msg)
          labels = _LogEventLabels(**event_dict.get("labels", {}))
  
          if "message" in event_dict:
              message = event_dict["message"]
              timestamp = dateutil.parser.isoparse(
                  event_dict["timestamp"]
              )
              event = _LogEvent(
                  message=message,
                  timestamp=timestamp,
                  component_name=component_name,
                  labels=labels,
              )
              read_queue.put(event)
  
      return callback
  
file_path: pytorch-lightning/src/lightning/app/utilities/app_logs.py
imports: import json
  import queue
  from dataclasses import dataclass
  from threading import Thread
  from typing import Callable, Iterator, List, Optional
  import dateutil.parser
  from websocket import WebSocketApp
  from lightning.app.utilities.log_helpers import _error_callback, _OrderedLogEntry
  from lightning.app.utilities.logs_socket_api import _LightningLogsSocketAPI
label_desc: Use image node_id 1 for calling a global function with example usage: _push_log_events_to_read_queue_callback(component_name, read_queue) and returns: callback