Željko Filipin
Željko Filipin

Reputation: 57312

How to catch XML packets that ConsoleExport Firebug extension sends?

I have installed ConsoleExport Firebug extension. I have enabled auto-export feature at about:config by setting extensions.firebug.consoleexport.active to true. I have opened a page with JavaScript error, for example http://www.random.org. I have enabled Firebug, reloaded the page. I can see the error in log:

uncaught exception: Error: Permission denied for <https://www.facebook.com> to get property Proxy.InstallTrigger

The ConsoleExport page says:

You can also activate an auto-export feature that is sending individual logs into specified server as XML packets.

I know I should set extensions.firebug.consoleexport.serverURL to server URL. I do not know how to catch XML packets that ConsoleExport sends.

For example, I know how to set up Apache on Mac, but what then? How to catch XML packets?

Environment:

I have access to Windows and Linux machines, if the server that catches XML packets is easier to set up there.

Upvotes: 1

Views: 704

Answers (2)

Sebastian Zartner
Sebastian Zartner

Reputation: 20125

It sounds like it simply sends the XML data via an AJAX request to that URL. So you need to define a script, that handles that XML data.

E.g. when you use PHP, you could set the serverURL preference to http://localhost/handleFBConsoleOutput.php. That script could then look like this:

<?php
  $filename = '/path/to/log/file/consoleexport.log';

  if (!$handle = fopen($filename, 'a'))
  {
    echo 'File "'.$filename.'" could not be opened';
    exit;
  }

  ob_start();
  var_dump($_POST);
  $content = ob_get_contents();
  ob_clean();

  if (!fwrite($handle, $content))
  {
    echo 'Can\'t write into file "'.$filename.'"';
    exit;
  }

  echo 'Done!';
  fclose($handle);
?>

The code shown here writes a dump of all POST parameters. You might want to specify the exact parameter as output by replacing the $content variable by $_POST['param_name'], where param_name is the name of the parameter holding the XML contents, and remove the ob_start(); ... ob_clean(); block.

As reference: The same issue was asked at the Firebug discussion group.

Upvotes: 1

Jan Odvarko
Jan Odvarko

Reputation: 431

Modified script fixing a problem with getting the posted data:

Note that the content-Type of the posted data is application/xml

<?php
  $filename = 'consoleexport.log';

  if (!$handle = fopen($filename, 'a'))
  {
    echo 'File "'.$filename.'" could not be opened';
    exit;
  }

  ob_start();
  $content = file_get_contents('php://input');
  $content .= "\n";
  ob_clean();

  if (!fwrite($handle, $content))
  {
    echo 'Can\'t write into file "'.$filename.'"';
    exit;
  }

  echo 'Done!';
  fclose($handle);
?>

Honza

Upvotes: 2

Related Questions