title: Gstreamer debug pipeline c++
body: <p>I am trying to transcode a gstreamer bash script to c++ code, y but I am not able to save de debuggin log into a file</p>
  
  <p>This is my code </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>int main(int argc, char *argv[])
  {
        YoctoLinuxSystem* hola;
        //hola-&gt;YoctoLinuxSystem();
  
  
  
     CustomData DataTest, DataDvi;
     GstBus *bus;
     GstMessage *msg;
     GstStateChangeReturn ret;
     GMainLoop *loop; 
     
  
  
     //vector&lt;string&gt; lines = YoctoLinuxSystem::getCmdOutputAsLines("./scripts/get_system_temps.sh");
     
  
       gst_init (&amp;argc, &amp;argv);
  
    loop = g_main_loop_new (NULL, FALSE);
    
    /******************************/
    /****AJUSTES GSTREAMER TEST****/
    /******************************/
  
    DataTest.source = gst_element_factory_make ("videotestsrc", "source");
    DataTest.capsfilter = gst_element_factory_make ("capsfilter","caps");
    DataTest.sink = gst_element_factory_make ("imxipuvideosink", "sink");
    
  
    DataTest.pipeline = gst_pipeline_new ("test-pipeline"); 
    
      if (!DataTest.pipeline || !DataTest.source || !DataTest.capsfilter || !DataTest.sink) {
       g_printerr ("Not all elements could be created.\n");
       return -1;
     }  
  
     /* Modify the source's properties */
     g_object_set (DataTest.source, "pattern", 0, NULL);
     g_object_set(DataTest.capsfilter, "caps", gst_caps_new_simple("video/x-raw", "framerate", GST_TYPE_FRACTION, 25, 1,"width", G_TYPE_INT, 1920, "height", G_TYPE_INT, 1080, "format", G_TYPE_STRING, "RGB", NULL), NULL);
     
  
     /* Build the pipeline */
     gst_bin_add_many (GST_BIN (DataTest.pipeline), DataTest.source, DataTest.capsfilter, DataTest.sink, NULL);
  
     if (gst_element_link (DataTest.source, DataTest.capsfilter) != TRUE) {
       g_printerr ("Elements source-caps could not be linked.\n");
       gst_object_unref (DataTest.pipeline);
       return -1;
     }
  
     if (gst_element_link (DataTest.capsfilter, DataTest.sink) != TRUE) {
       g_printerr ("Elements caps-sink could not be linked.\n");
       gst_object_unref (DataTest.pipeline);
       return -1;
     }
  
      gst_element_link_many (DataTest.source, DataTest.capsfilter, DataTest.sink, NULL);
      
      
      /******************************/
      /****AJUSTES GSTREAMER DVI****/
      /******************************/
      DataDvi.source = gst_element_factory_make ("v4l2src", "source");
      DataDvi.sink = gst_element_factory_make ("imxipuvideosink", "sink");
        
  
      DataDvi.pipeline = gst_pipeline_new ("test-pipeline"); 
        
      if (!DataDvi.pipeline || !DataDvi.source || !DataDvi.sink) {
           g_printerr ("Not all elements could be created.\n");
           return -1;
      }  
  
         /* Modify the source's properties */
      g_object_set (DataDvi.source, "device", "/dev/video0", NULL);
             
  
         /* Build the pipeline */
      gst_bin_add_many (GST_BIN (DataDvi.pipeline), DataDvi.source, DataDvi.sink, NULL);
  
      
      if (gst_element_link (DataDvi.source, DataDvi.sink) != TRUE) {
           g_printerr ("Elements caps-sink could not be linked.\n");
           gst_object_unref (DataDvi.pipeline);
           return -1;
      }
  
      gst_element_link_many (DataDvi.source, DataDvi.sink, NULL);
          
          
      GST_DEBUG=2;
          
      ifstream fileread;
     // fileread.open("/var/log/data.log");
      
    while(1)
    {     
     ifstream fileread("/var/log/data.log");
    
     if (!fileread.good())
     {
      /* Start playing */
      //g_print ("Now playing: \n");
      gst_element_set_state (DataDvi.pipeline, GST_STATE_PAUSED);
      ret = gst_element_set_state (DataTest.pipeline, GST_STATE_PLAYING);
      if (ret == GST_STATE_CHANGE_FAILURE) {
     g_printerr ("Unable to set the pipeline to the playing state.\n");
     gst_object_unref (DataTest.pipeline);
     return -1;
      }
     }
     
     else
     {
      gst_element_set_state (DataTest.pipeline, GST_STATE_PAUSED);
      ret = gst_element_set_state (DataDvi.pipeline, GST_STATE_PLAYING);
             
             /*HERE I NEED TO KNOW THE DEBUG OF THE PIPELINE*/
             
      if (ret == GST_STATE_CHANGE_FAILURE) {
       g_printerr ("Unable to set the pipeline to the playing state.\n");
       gst_object_unref (DataDvi.pipeline);
       return -1;
      }
     }
    }
    
      g_print ("SALE\n");
    return 0;
   }</code></pre>
  </div>
  </div>
  </p>
  
  <p>I am using gstreamer-1.0 library and I have seen that I need use GST_DEBUG_FILE but I do not know how call these functions from c++.</p>
  
  <p>Thanks for the help!</p>