Skip to content

Commit

Permalink
Merge pull request #98 from infabo/feature/js-block
Browse files Browse the repository at this point in the history
skip frontend-logger if isDevAllowed
  • Loading branch information
daim2k5 authored Feb 5, 2017
2 parents d48d965 + 21d8a2d commit aaa37e6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
22 changes: 17 additions & 5 deletions src/app/code/community/FireGento/Logger/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @copyright 2013 FireGento Team (http://www.firegento.com)
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
*/

/**
* Observer Class
*
Expand All @@ -32,6 +33,11 @@ class FireGento_Logger_Model_Observer extends Varien_Object
*/
const MAX_FILE_DAYS = 30;

/**
* @var bool
*/
protected $init = true;

/**
* Cron job for cleaning firegento log table
*/
Expand Down Expand Up @@ -76,8 +82,8 @@ public function rotateLogs()
/**
* Get all files which are older than X days and containing a pattern.
*
* @param int $days Days
* @param string $dir Directory
* @param int $days Days
* @param string $dir Directory
* @param string $filename Filename
* @return array
*/
Expand Down Expand Up @@ -137,15 +143,21 @@ public function formatDate($date)
*/
public function addLoggerJs(Varien_Event_Observer $observer)
{
$isHeadBlock = ($observer->getBlock() instanceof Mage_Page_Block_Html_Head);
$isFrontendLoggerActivated = (boolean) Mage::helper('firegento_logger')->getLoggerConfig('general/frontend_logger');
if ($isHeadBlock && $isFrontendLoggerActivated) {
if ($this->init && Mage::helper('core')->isDevAllowed()) {
$this->init = false;
}

if ($this->init && $observer->getBlock()->getNameInLayout() === 'head'
&& (boolean)Mage::helper('firegento_logger')->getLoggerConfig('general/frontend_logger')
) {
$transport = $observer->getTransport();
$html = $transport->getHtml();
$block = Mage::app()->getLayout()->createBlock('core/template');
$block->setTemplate('firegento_logger/js.phtml');
$html = $block->toHtml() . $html;
$transport->setHtml($html);

$this->init = false;
}
}
}
1 change: 1 addition & 0 deletions src/app/code/community/FireGento/Logger/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ confirmation]]></filter_request_data>
<core_block_abstract_to_html_after>
<observers>
<add_logger_js>
<type>singleton</type>
<class>FireGento_Logger_Model_Observer</class>
<method>addLoggerJs</method>
</add_logger_js>
Expand Down
3 changes: 2 additions & 1 deletion src/app/code/community/FireGento/Logger/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@
<show_in_default>1</show_in_default>
<comment><![CDATA[
When set to "Yes", JS errors in the frontend will be send to an action to
send these errors also to the configured logging backend. <br />
send these errors also to the configured logging backend. <br> />
Note: only if client is not defined in dev/restrict/allow_ips <br />
]]></comment>
</frontend_logger>
<viewer_enabled translate="label">
Expand Down

0 comments on commit aaa37e6

Please sign in to comment.