A recent task was to integrate a client website with Airbrake.

Simple enough task, since Airbrake supplies a working magento module via github: https://github.com/airbrake/Airbrake-Magento

Unfortunately, integration was not as simple as initially thought, due to the Airbrake extension, and my own Newrelic extension clashing. They both try and replace the log stream writer.  refer to this article for more information on how log stream can be replaced by a custom stream writer: http://www.proxiblue.com.au/blog/intercept-log-writing/

I needed a way to allow them logging at the same time.

Firegento Logger to the rescue.

The only step I had to do was integrate the Airbrake solution into the logger. Adjusting the newrelic extension to work with the logger is already known, and documented in the extensions readme.

The only issue with the integration into the logger was how Airbrake hooks to get  REPORT based exceptions. This requires adjusting a core magento file, in the errors/ folder. Unfortunately there does not seem to be another way, as the mini errors-framework magento built for the reporting is not extensible.

I did not feel that including that change into the logger codebase was acceptable. The change required is documented below.

Note that Airbrake will work 100% without this change. You wimply will not get report exceptions sent to Airbrake.

Edit the following file:

<magento-root>/errors/report.php

file looks like this:

<?php

require_once 'processor.php';
$processor = new Error_Processor();
if (isset($reportData) && is_array($reportData)) {
$processor->saveReport($reportData);
}
$processor->processReport();

and replace with

<?php

require_once 'processor.php';
$processor = new Error_Processor();
if (isset($reportData) && is_array($reportData)) {
$processor->saveReport($reportData);
/**
* Airbrake hook to push report to API
* Integrated as part of FireGento Logger
*/
$modules = Mage::getConfig()->getNode('modules')->children();
$modulesArray = (array)$modules;
if(isset($modulesArray['FireGento_Logger'])) {
Mage::getModel('firegento_logger/airbrake')->insertException($reportData);
}
}
$processor->processReport();
 

Available on github: https://github.com/ProxiBlue/firegento-logger/tree/airbrake