code: def log_(
      message: str,
      logger: logging.Logger,
      level: str = "info",
      extra: Optional[Dict] = None,
      trim: bool = False,
  ) -> None:
      
      if extra is None:
          extra = {}
      # Clean up the message for logging
      if message:
          message = message.replace("\n", "").replace("  ", " ").replace("{ ", "{")
      if trim:
          message = _trim_message(message)
      # Log.
      getattr(logger, level)(message, extra=extra)
docs: Log a request or response
  
      Args:
          message: JSON-RPC request or response string.
          level: Log level.
          extra: More details to include in the log entry.
          trim: Abbreviate log messages.