-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from firegento/develop
Merge Develop to Master
- Loading branch information
Showing
16 changed files
with
604 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
src/app/code/community/FireGento/Logger/Block/Adminhtml/Logger/Manager.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
/** | ||
* This file is part of a FireGento e.V. module. | ||
* | ||
* This FireGento e.V. module is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License version 3 as | ||
* published by the Free Software Foundation. | ||
* | ||
* This script is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
* | ||
* | ||
* @category FireGento | ||
* @package FireGento_Logger | ||
* @author FireGento Team <[email protected]> | ||
* @copyright 2013 FireGento Team (http://www.firegento.com) | ||
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3) | ||
*/ | ||
/** | ||
* Block for manage modules log output in the backend | ||
* | ||
* @category FireGento | ||
* @package FireGento_Logger | ||
* @author FireGento Team <[email protected]> | ||
*/ | ||
class FireGento_Logger_Block_Adminhtml_Logger_Manager extends Mage_Core_Block_Template | ||
{ | ||
|
||
/** | ||
* Local store of the list of modules | ||
* @var array | ||
*/ | ||
protected $_lists = array(); | ||
|
||
public function _construct() | ||
{ | ||
$this->gather(); | ||
return parent::_construct(); | ||
} | ||
|
||
/** | ||
* Inspiration for this code was from Alan Storm's module list extension. | ||
* Be sure to check it out some time at http://alanstorm.com/magento_list_module | ||
* @return $this | ||
*/ | ||
public function gather() | ||
{ | ||
$config = Mage::getConfig(); | ||
foreach ($config->getNode('modules')->children() as $item) { | ||
$o = new Varien_Object(); | ||
$o->setName($item->getName()); | ||
$o->setActive((string)$item->active); | ||
$o->setCodePool((string)$item->codePool); | ||
$isLogEnabled = Mage::getSingleton('firegento_logger/manager')->isEnabled($item->getName()); | ||
$o->setLogEnabled($isLogEnabled); | ||
//use same logic from Mage_Core_Model_Config::getModuleDir | ||
//but recreated here to allow for poorly configued modules | ||
$codePool = $config->getModuleConfig($item->getName())->codePool; | ||
$dir = $config->getOptions()->getCodeDir().DS.$codePool.DS.uc_words($item->getName(),DS); | ||
$o->setPath($dir); | ||
$exists = file_exists($o->getPath()); | ||
$exists = $exists ? 'yes' : 'no'; | ||
$o->setPathExists($exists); | ||
$exists = file_exists($o->getPath() . DS . 'etc'.DS.'config.xml'); | ||
$exists = $exists ? 'yes' : 'no'; | ||
$o->setConfigExists($exists); | ||
if(!array_key_exists($o->getCodePool(), $this->_lists)) { | ||
$this->_lists[$o->getCodePool()] = array(); | ||
} | ||
$this->_lists[$o->getCodePool()][] = $o->toArray(); | ||
} | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getModules() | ||
{ | ||
$modules = array_merge($this->_lists['local'], $this->_lists['community']); | ||
return $modules; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
src/app/code/community/FireGento/Logger/Model/Manager.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<?php | ||
/** | ||
* This file is part of a FireGento e.V. module. | ||
* | ||
* This FireGento e.V. module is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License version 3 as | ||
* published by the Free Software Foundation. | ||
* | ||
* This script is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
* | ||
* | ||
* @category FireGento | ||
* @package FireGento_Logger | ||
* @author FireGento Team <[email protected]> | ||
* @copyright 2013 FireGento Team (http://www.firegento.com) | ||
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3) | ||
*/ | ||
/** | ||
* Log Manager | ||
* | ||
* @category FireGento | ||
* @package FireGento_Logger | ||
* @author FireGento Team <[email protected]> | ||
*/ | ||
class FireGento_Logger_Model_Manager extends Varien_Object | ||
{ | ||
/** | ||
* This is a local store of configured disabled log modules | ||
* @var null | ||
*/ | ||
protected $_cfg = null; | ||
|
||
/** | ||
* Provide an extension key (ie TBT_Rewards) to disable the logging output from that module. | ||
* @param string $moduleKey | ||
* @return $this | ||
*/ | ||
public function disableLogging($moduleKey) | ||
{ | ||
return $this->toggleLogging($moduleKey, false); | ||
} | ||
|
||
/** | ||
* Provide an extension key (ie TBT_Rewards) to enable the logging output from that module. | ||
* @param string $moduleKey | ||
* @return $this | ||
*/ | ||
public function enableLogging($moduleKey) | ||
{ | ||
return $this->toggleLogging($moduleKey, true); | ||
} | ||
|
||
/** | ||
* Provide an extension key (ie TBT_Rewards) to disable the logging output from that module. | ||
* @param string $moduleKey | ||
* @param bool $disable if true, log output will be disabled for the specified module. | ||
* @return $this | ||
*/ | ||
public function toggleLogging($moduleKey, $disable) | ||
{ | ||
$oldCfg = $this->_getCfg(); | ||
$key = array_search($moduleKey, $oldCfg); | ||
if ($disable) { | ||
if ($key !== false) { | ||
unset($oldCfg[$key]); | ||
} | ||
} else { | ||
if ($key === false) { | ||
$oldCfg[] = $moduleKey; | ||
} | ||
} | ||
$newCfg = implode(",", $oldCfg); | ||
$cfg = new Mage_Core_Model_Config(); | ||
$cfg ->saveConfig('dev/log/disabled_modules', $newCfg, 'default', 0); | ||
return $this; | ||
} | ||
|
||
|
||
/** | ||
* Tells you if an extension's log output is currently enabled | ||
* @param string $moduleKey | ||
* @return boolean | ||
*/ | ||
public function isEnabled($moduleKey) | ||
{ | ||
$cfg = $this->_getCfg(); | ||
$key = array_search($moduleKey, $cfg); | ||
if ($key !== false) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
/** | ||
* Get the local store of config values | ||
* @return array | ||
*/ | ||
protected function _getCfg() | ||
{ | ||
if ($this->_cfg != null) { | ||
return $this->_cfg; | ||
} | ||
$cfg = Mage::getStoreConfig("dev/log/disabled_modules"); | ||
if (empty($cfg)) { | ||
$this->_cfg = array(); | ||
} else { | ||
$this->_cfg = explode(",", $cfg); | ||
} | ||
return $this->_cfg; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/app/code/community/FireGento/Logger/Model/Papertrail/PapertrailSyslogMessage.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
/** | ||
* This file is part of a FireGento e.V. module. | ||
* | ||
* This FireGento e.V. module is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License version 3 as | ||
* published by the Free Software Foundation. | ||
* | ||
* This script is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
* | ||
* PHP version 5 | ||
* | ||
* @category FireGento | ||
* @package FireGento_Logger | ||
* @author FireGento Team <[email protected]> | ||
* @copyright 2013 FireGento Team (http://www.firegento.com) | ||
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3) | ||
*/ | ||
/** | ||
* Implementation of Remote Syslog Message for Papertrail. | ||
* | ||
* @category FireGento | ||
* @package FireGento_Logger | ||
* @author FireGento Team <[email protected]> | ||
*/ | ||
class FireGento_Logger_Model_Papertrail_PapertrailSyslogMessage extends SyslogMessage | ||
{ | ||
|
||
/** | ||
* Puts all Log Message elements together to form a string that will be passed | ||
* to the Papertrail Server. | ||
* | ||
* @return string The Message as a string. | ||
*/ | ||
protected function FormatMessage() { | ||
return sprintf('%s %s', | ||
$this->Facility, | ||
$this->Message | ||
); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function GetMessageChunks() | ||
{ | ||
return array($this->FormatMessage()); | ||
} | ||
} |
Oops, something went wrong.