Skip to content

Commit aaa37e6

Browse files
authored
Merge pull request #98 from infabo/feature/js-block
skip frontend-logger if isDevAllowed
2 parents d48d965 + 21d8a2d commit aaa37e6

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

src/app/code/community/FireGento/Logger/Model/Observer.php

+17-5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* @copyright 2013 FireGento Team (http://www.firegento.com)
1919
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
2020
*/
21+
2122
/**
2223
* Observer Class
2324
*
@@ -32,6 +33,11 @@ class FireGento_Logger_Model_Observer extends Varien_Object
3233
*/
3334
const MAX_FILE_DAYS = 30;
3435

36+
/**
37+
* @var bool
38+
*/
39+
protected $init = true;
40+
3541
/**
3642
* Cron job for cleaning firegento log table
3743
*/
@@ -76,8 +82,8 @@ public function rotateLogs()
7682
/**
7783
* Get all files which are older than X days and containing a pattern.
7884
*
79-
* @param int $days Days
80-
* @param string $dir Directory
85+
* @param int $days Days
86+
* @param string $dir Directory
8187
* @param string $filename Filename
8288
* @return array
8389
*/
@@ -137,15 +143,21 @@ public function formatDate($date)
137143
*/
138144
public function addLoggerJs(Varien_Event_Observer $observer)
139145
{
140-
$isHeadBlock = ($observer->getBlock() instanceof Mage_Page_Block_Html_Head);
141-
$isFrontendLoggerActivated = (boolean) Mage::helper('firegento_logger')->getLoggerConfig('general/frontend_logger');
142-
if ($isHeadBlock && $isFrontendLoggerActivated) {
146+
if ($this->init && Mage::helper('core')->isDevAllowed()) {
147+
$this->init = false;
148+
}
149+
150+
if ($this->init && $observer->getBlock()->getNameInLayout() === 'head'
151+
&& (boolean)Mage::helper('firegento_logger')->getLoggerConfig('general/frontend_logger')
152+
) {
143153
$transport = $observer->getTransport();
144154
$html = $transport->getHtml();
145155
$block = Mage::app()->getLayout()->createBlock('core/template');
146156
$block->setTemplate('firegento_logger/js.phtml');
147157
$html = $block->toHtml() . $html;
148158
$transport->setHtml($html);
159+
160+
$this->init = false;
149161
}
150162
}
151163
}

src/app/code/community/FireGento/Logger/etc/config.xml

+1
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ confirmation]]></filter_request_data>
271271
<core_block_abstract_to_html_after>
272272
<observers>
273273
<add_logger_js>
274+
<type>singleton</type>
274275
<class>FireGento_Logger_Model_Observer</class>
275276
<method>addLoggerJs</method>
276277
</add_logger_js>

src/app/code/community/FireGento/Logger/etc/system.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@
119119
<show_in_default>1</show_in_default>
120120
<comment><![CDATA[
121121
When set to "Yes", JS errors in the frontend will be send to an action to
122-
send these errors also to the configured logging backend. <br />
122+
send these errors also to the configured logging backend. <br> />
123+
Note: only if client is not defined in dev/restrict/allow_ips <br />
123124
]]></comment>
124125
</frontend_logger>
125126
<viewer_enabled translate="label">

0 commit comments

Comments
 (0)