Version Notes
New featues: Automatically E-Mail Logs with specified type; Send by Mail - Button in Detail View.
Download this release
Release Info
| Developer | Bastian Zagar |
| Extension | LoggingHelper |
| Version | 1.3.0 |
| Comparing to | |
| See all releases | |
Code changes from version 1.2.0 to 1.3.0
- app/code/local/MageDeveloper/Logging/Block/Adminhtml/Logging/Grid.php +58 -2
- app/code/local/MageDeveloper/Logging/Block/Adminhtml/Logging/View.php +16 -0
- app/code/local/MageDeveloper/Logging/Block/Adminhtml/Logging/View/Form.php +6 -0
- app/code/local/MageDeveloper/Logging/Helper/Config.php +121 -0
- app/code/local/MageDeveloper/Logging/Helper/Data.php +87 -1
- app/code/local/MageDeveloper/Logging/Helper/Log.php +50 -1
- app/code/local/MageDeveloper/Logging/Helper/Logtype.php +24 -0
- app/code/local/MageDeveloper/Logging/Model/Log.php +74 -1
- app/code/local/MageDeveloper/Logging/Model/Mysql4/Log/Collection.php +44 -0
- app/code/local/MageDeveloper/Logging/Model/Source/Types.php +68 -0
- app/code/local/MageDeveloper/Logging/controllers/Adminhtml/LoggingController.php +18 -6
- app/code/local/MageDeveloper/Logging/etc/config.xml +20 -1
- app/code/local/MageDeveloper/Logging/etc/system.xml +72 -0
- app/code/local/MageDeveloper/Logging/sql/magedeveloper_logging_setup/mysql4-upgrade-1.2.0-1.3.0.php +84 -0
- package.xml +5 -5
app/code/local/MageDeveloper/Logging/Block/Adminhtml/Logging/Grid.php
CHANGED
|
@@ -11,6 +11,12 @@
|
|
| 11 |
|
| 12 |
class MageDeveloper_Logging_Block_Adminhtml_Logging_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
| 13 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
public function __construct()
|
| 15 |
{
|
| 16 |
parent::__construct();
|
|
@@ -19,16 +25,65 @@ class MageDeveloper_Logging_Block_Adminhtml_Logging_Grid extends Mage_Adminhtml_
|
|
| 19 |
$this->setDefaultDir('desc');
|
| 20 |
$this->setSaveParametersInSession(true);
|
| 21 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
protected function _prepareCollection()
|
| 24 |
{
|
| 25 |
-
|
| 26 |
-
->getCollection();
|
| 27 |
|
| 28 |
$this->setCollection($collection);
|
| 29 |
|
| 30 |
return parent::_prepareCollection();
|
| 31 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
protected function _prepareColumns()
|
| 34 |
{
|
|
@@ -54,6 +109,7 @@ class MageDeveloper_Logging_Block_Adminhtml_Logging_Grid extends Mage_Adminhtml_
|
|
| 54 |
MageDeveloper_Logging_Model_Log::LOG_TYPE_INFO => Mage::helper('logging')->__('INFO'),
|
| 55 |
MageDeveloper_Logging_Model_Log::LOG_TYPE_WARNING => Mage::helper('logging')->__('WARNING'),
|
| 56 |
MageDeveloper_Logging_Model_Log::LOG_TYPE_ERROR => Mage::helper('logging')->__('ERROR'),
|
|
|
|
| 57 |
),
|
| 58 |
));
|
| 59 |
|
| 11 |
|
| 12 |
class MageDeveloper_Logging_Block_Adminhtml_Logging_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
| 13 |
{
|
| 14 |
+
/**
|
| 15 |
+
* Collection
|
| 16 |
+
* @var MageDeveloper_Logging_Model_Mysql4_Log_Collection
|
| 17 |
+
*/
|
| 18 |
+
protected $_collection;
|
| 19 |
+
|
| 20 |
public function __construct()
|
| 21 |
{
|
| 22 |
parent::__construct();
|
| 25 |
$this->setDefaultDir('desc');
|
| 26 |
$this->setSaveParametersInSession(true);
|
| 27 |
}
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
* Get the logging collection
|
| 31 |
+
*
|
| 32 |
+
* @return MageDeveloper_Logging_Model_Mysql4_Log_Collection
|
| 33 |
+
*/
|
| 34 |
+
public function getCollection()
|
| 35 |
+
{
|
| 36 |
+
if (!$this->_collection) {
|
| 37 |
+
$this->_collection = Mage::getModel('logging/log')
|
| 38 |
+
->getCollection();
|
| 39 |
+
}
|
| 40 |
+
return $this->_collection;
|
| 41 |
+
}
|
| 42 |
|
| 43 |
protected function _prepareCollection()
|
| 44 |
{
|
| 45 |
+
$collection = $this->getCollection();
|
|
|
|
| 46 |
|
| 47 |
$this->setCollection($collection);
|
| 48 |
|
| 49 |
return parent::_prepareCollection();
|
| 50 |
}
|
| 51 |
+
|
| 52 |
+
/**
|
| 53 |
+
* Get the row class
|
| 54 |
+
*
|
| 55 |
+
* @param $row
|
| 56 |
+
* @return string
|
| 57 |
+
*/
|
| 58 |
+
public function getRowClass($row)
|
| 59 |
+
{
|
| 60 |
+
$class = parent::getRowClass();
|
| 61 |
+
|
| 62 |
+
if ($this->isTodayRow($row)) {
|
| 63 |
+
$class .= ' ' . 'on-mouse';
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
return $class;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
/**
|
| 70 |
+
* Checks if the row is from today
|
| 71 |
+
*
|
| 72 |
+
* @return bool true if today
|
| 73 |
+
*/
|
| 74 |
+
public function isTodayRow($row)
|
| 75 |
+
{
|
| 76 |
+
$collection = $this->getCollection()
|
| 77 |
+
->addTodayFilter();
|
| 78 |
+
|
| 79 |
+
$id = $row->getId();
|
| 80 |
+
|
| 81 |
+
$ids = $collection->getAllIds();
|
| 82 |
+
if (in_array($id, $ids)) {
|
| 83 |
+
return true;
|
| 84 |
+
}
|
| 85 |
+
return false;
|
| 86 |
+
}
|
| 87 |
|
| 88 |
protected function _prepareColumns()
|
| 89 |
{
|
| 109 |
MageDeveloper_Logging_Model_Log::LOG_TYPE_INFO => Mage::helper('logging')->__('INFO'),
|
| 110 |
MageDeveloper_Logging_Model_Log::LOG_TYPE_WARNING => Mage::helper('logging')->__('WARNING'),
|
| 111 |
MageDeveloper_Logging_Model_Log::LOG_TYPE_ERROR => Mage::helper('logging')->__('ERROR'),
|
| 112 |
+
MageDeveloper_Logging_Model_Log::LOG_TYPE_TIME => Mage::helper('logging')->__('TIME'),
|
| 113 |
),
|
| 114 |
));
|
| 115 |
|
app/code/local/MageDeveloper/Logging/Block/Adminhtml/Logging/View.php
CHANGED
|
@@ -32,6 +32,11 @@ class MageDeveloper_Logging_Block_Adminhtml_Logging_View extends Mage_Adminhtml_
|
|
| 32 |
'onclick' => 'setLocation(\'' . $nextUrl . '\')',
|
| 33 |
), -1);
|
| 34 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
$this->removeButton('reset');
|
| 37 |
$this->removeButton('save');
|
|
@@ -73,6 +78,17 @@ class MageDeveloper_Logging_Block_Adminhtml_Logging_View extends Mage_Adminhtml_
|
|
| 73 |
return false;
|
| 74 |
}
|
| 75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
/**
|
| 77 |
* Get the id of the next log entry
|
| 78 |
*
|
| 32 |
'onclick' => 'setLocation(\'' . $nextUrl . '\')',
|
| 33 |
), -1);
|
| 34 |
}
|
| 35 |
+
$this->_addButton('mail', array(
|
| 36 |
+
'label' => Mage::helper('logging')->__('Send mail'),
|
| 37 |
+
'onclick' => 'setLocation(\'' . $this->getSendMailUrl() . '\')',
|
| 38 |
+
'class' => 'add success'
|
| 39 |
+
), -1);
|
| 40 |
|
| 41 |
$this->removeButton('reset');
|
| 42 |
$this->removeButton('save');
|
| 78 |
return false;
|
| 79 |
}
|
| 80 |
|
| 81 |
+
/**
|
| 82 |
+
* Get the url to send the log by mail
|
| 83 |
+
*
|
| 84 |
+
* @return string
|
| 85 |
+
*/
|
| 86 |
+
public function getSendMailUrl()
|
| 87 |
+
{
|
| 88 |
+
$id = $this->getRequest()->getParam($this->_objectId);
|
| 89 |
+
return $this->getUrl('*/*/mail', array($this->_objectId => $id));
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
/**
|
| 93 |
* Get the id of the next log entry
|
| 94 |
*
|
app/code/local/MageDeveloper/Logging/Block/Adminhtml/Logging/View/Form.php
CHANGED
|
@@ -60,6 +60,12 @@ class MageDeveloper_Logging_Block_Adminhtml_Logging_View_Form extends Mage_Admin
|
|
| 60 |
'value' => $log->getOutput()
|
| 61 |
));
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
return parent::_prepareForm();
|
| 65 |
}
|
| 60 |
'value' => $log->getOutput()
|
| 61 |
));
|
| 62 |
|
| 63 |
+
$fieldset->addField('trace', 'output', array(
|
| 64 |
+
'label' => Mage::helper('logging')->__('Backtrace'),
|
| 65 |
+
'value' => $log->getTrace()
|
| 66 |
+
));
|
| 67 |
+
|
| 68 |
+
|
| 69 |
|
| 70 |
return parent::_prepareForm();
|
| 71 |
}
|
app/code/local/MageDeveloper/Logging/Helper/Config.php
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* MageDeveloper Logging Module
|
| 4 |
+
* ----------------------------
|
| 5 |
+
*
|
| 6 |
+
* @category Mage
|
| 7 |
+
* @package MageDeveloper_Logging
|
| 8 |
+
* @copyright Magento Developers / magedeveloper.de
|
| 9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
class MageDeveloper_Logging_Helper_Config extends Mage_Core_Helper_Abstract
|
| 13 |
+
{
|
| 14 |
+
/**
|
| 15 |
+
* XML Configuration Paths
|
| 16 |
+
* @var string
|
| 17 |
+
*/
|
| 18 |
+
const XML_PATH_ENABLE_LOGGING_MAILS = 'logging/mail_settings/enable_mails';
|
| 19 |
+
const XML_PATH_TYPE_SELECT = 'logging/mail_settings/typeselect';
|
| 20 |
+
const XML_PATH_RECIPIENTS = 'logging/mail_settings/recipients';
|
| 21 |
+
const XML_PATH_SENDER = 'logging/mail_settings/sender';
|
| 22 |
+
const XML_PATH_MAIL_TEMPLATE = 'logging/mail_settings/template';
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* Get the configuration setting for enabled logging mails
|
| 26 |
+
*
|
| 27 |
+
* @return bool
|
| 28 |
+
*/
|
| 29 |
+
public function isLoggingMailEnabled()
|
| 30 |
+
{
|
| 31 |
+
return (bool)Mage::getStoreConfig(self::XML_PATH_ENABLE_LOGGING_MAILS);
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
/**
|
| 35 |
+
* Get the selected types in the backend configuration
|
| 36 |
+
*
|
| 37 |
+
* @return array
|
| 38 |
+
*/
|
| 39 |
+
public function getSelectedTypes()
|
| 40 |
+
{
|
| 41 |
+
$config = Mage::getStoreConfig(self::XML_PATH_TYPE_SELECT);
|
| 42 |
+
$types = array();
|
| 43 |
+
|
| 44 |
+
if ($config) {
|
| 45 |
+
$types = explode(',', $config);
|
| 46 |
+
}
|
| 47 |
+
return $types;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
/**
|
| 51 |
+
* Get the mail template id from the configuration settings
|
| 52 |
+
*
|
| 53 |
+
* @return int
|
| 54 |
+
*/
|
| 55 |
+
public function getMailTemplateId()
|
| 56 |
+
{
|
| 57 |
+
return (int)Mage::getStoreConfig(self::XML_PATH_MAIL_TEMPLATE);
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
/**
|
| 61 |
+
* Get the configuration setting for the mail recipients
|
| 62 |
+
*
|
| 63 |
+
* @return array
|
| 64 |
+
*/
|
| 65 |
+
public function getRecipients()
|
| 66 |
+
{
|
| 67 |
+
$config = Mage::getStoreConfig(self::XML_PATH_RECIPIENTS);
|
| 68 |
+
$recipients = array();
|
| 69 |
+
|
| 70 |
+
if ($config) {
|
| 71 |
+
$recipients = explode(';', $config);
|
| 72 |
+
}
|
| 73 |
+
return $recipients;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
/**
|
| 77 |
+
* Get sender ident
|
| 78 |
+
*
|
| 79 |
+
* @return string
|
| 80 |
+
*/
|
| 81 |
+
public function getSenderIdent()
|
| 82 |
+
{
|
| 83 |
+
return Mage::getStoreConfig(self::XML_PATH_SENDER);
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
/**
|
| 87 |
+
* Get sender name
|
| 88 |
+
*
|
| 89 |
+
* @return string
|
| 90 |
+
*/
|
| 91 |
+
public function getSenderName()
|
| 92 |
+
{
|
| 93 |
+
$senderIdent = $this->getSenderIdent();
|
| 94 |
+
return Mage::getStoreConfig('trans_email/ident_'.$senderIdent.'/name');
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
/**
|
| 98 |
+
* Get sender email
|
| 99 |
+
*
|
| 100 |
+
* @return string
|
| 101 |
+
*/
|
| 102 |
+
public function getSenderMail()
|
| 103 |
+
{
|
| 104 |
+
$senderIdent = $this->getSenderIdent();
|
| 105 |
+
return Mage::getStoreConfig('trans_email/ident_'.$senderIdent.'/email');
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
/**
|
| 109 |
+
* Checks if an type is allowed for sending mail
|
| 110 |
+
*
|
| 111 |
+
* @param int $type Log Type
|
| 112 |
+
* @return bool
|
| 113 |
+
*/
|
| 114 |
+
public function isAllowedToSendMail($type)
|
| 115 |
+
{
|
| 116 |
+
if ($this->isLoggingMailEnabled() && in_array($type, $this->getSelectedTypes())) {
|
| 117 |
+
return true;
|
| 118 |
+
}
|
| 119 |
+
return false;
|
| 120 |
+
}
|
| 121 |
+
}
|
app/code/local/MageDeveloper/Logging/Helper/Data.php
CHANGED
|
@@ -86,6 +86,14 @@ class MageDeveloper_Logging_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 86 |
return MageDeveloper_Logging_Model_Log::LOG_TYPE_ERROR;
|
| 87 |
}
|
| 88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
/**
|
| 90 |
* Set OK Type
|
| 91 |
*
|
|
@@ -130,6 +138,17 @@ class MageDeveloper_Logging_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 130 |
return $this;
|
| 131 |
}
|
| 132 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
/**
|
| 134 |
* Get the model for a log entry
|
| 135 |
*
|
|
@@ -191,6 +210,16 @@ class MageDeveloper_Logging_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 191 |
return $this;
|
| 192 |
}
|
| 193 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
/**
|
| 195 |
* Dump data
|
| 196 |
*
|
|
@@ -286,6 +315,52 @@ class MageDeveloper_Logging_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 286 |
return $vars;
|
| 287 |
}
|
| 288 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
/**
|
| 290 |
* Create log entry
|
| 291 |
*/
|
|
@@ -302,7 +377,7 @@ class MageDeveloper_Logging_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 302 |
// last usable backtrace
|
| 303 |
$trace = reset($backtrace);
|
| 304 |
$trace = next($backtrace);
|
| 305 |
-
|
| 306 |
// Class
|
| 307 |
if (array_key_exists('class', $trace)) {
|
| 308 |
$this->getLog()
|
|
@@ -324,6 +399,11 @@ class MageDeveloper_Logging_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 324 |
->setMethod($method);
|
| 325 |
}
|
| 326 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 327 |
$errors = $this->getLog()->validate();
|
| 328 |
|
| 329 |
if (!is_array($errors)) {
|
|
@@ -340,6 +420,12 @@ class MageDeveloper_Logging_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 340 |
$id = $this->getLog()->getId();
|
| 341 |
|
| 342 |
if ($id) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 343 |
$this->_logModel->unsetData();
|
| 344 |
return $id;
|
| 345 |
}
|
| 86 |
return MageDeveloper_Logging_Model_Log::LOG_TYPE_ERROR;
|
| 87 |
}
|
| 88 |
|
| 89 |
+
/**
|
| 90 |
+
* Get TIME Type
|
| 91 |
+
*/
|
| 92 |
+
public function getTypeTime()
|
| 93 |
+
{
|
| 94 |
+
return MageDeveloper_Logging_Model_Log::LOG_TYPE_TIME;
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
/**
|
| 98 |
* Set OK Type
|
| 99 |
*
|
| 138 |
return $this;
|
| 139 |
}
|
| 140 |
|
| 141 |
+
/**
|
| 142 |
+
* Set TIME Type
|
| 143 |
+
*
|
| 144 |
+
* @return self
|
| 145 |
+
*/
|
| 146 |
+
public function setTypeTime()
|
| 147 |
+
{
|
| 148 |
+
$this->setType( $this->getTypeTime() );
|
| 149 |
+
return $this;
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
/**
|
| 153 |
* Get the model for a log entry
|
| 154 |
*
|
| 210 |
return $this;
|
| 211 |
}
|
| 212 |
|
| 213 |
+
/**
|
| 214 |
+
* Get the current set log data
|
| 215 |
+
*
|
| 216 |
+
* @return string
|
| 217 |
+
*/
|
| 218 |
+
public function getData()
|
| 219 |
+
{
|
| 220 |
+
return $this->_logData;
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
/**
|
| 224 |
* Dump data
|
| 225 |
*
|
| 315 |
return $vars;
|
| 316 |
}
|
| 317 |
|
| 318 |
+
/**
|
| 319 |
+
* Creates an formated backtrace string
|
| 320 |
+
*
|
| 321 |
+
* @return string
|
| 322 |
+
*/
|
| 323 |
+
private function _trace()
|
| 324 |
+
{
|
| 325 |
+
$backtrace = debug_backtrace();
|
| 326 |
+
$traceStr = '';
|
| 327 |
+
|
| 328 |
+
if ($backtrace) {
|
| 329 |
+
$i = count($backtrace);
|
| 330 |
+
foreach ($backtrace as $_key=>$_trace) {
|
| 331 |
+
if (array_key_exists('class', $_trace)) {
|
| 332 |
+
$traceStr .= '#'.$i.' '.$_trace['class'].'::'.$_trace['function']."\r\n";
|
| 333 |
+
$i--;
|
| 334 |
+
}
|
| 335 |
+
}
|
| 336 |
+
}
|
| 337 |
+
return $traceStr;
|
| 338 |
+
}
|
| 339 |
+
|
| 340 |
+
/**
|
| 341 |
+
* Log a timestamp
|
| 342 |
+
*
|
| 343 |
+
* @return self
|
| 344 |
+
*/
|
| 345 |
+
public function time()
|
| 346 |
+
{
|
| 347 |
+
$this->setPrintr();
|
| 348 |
+
$this->setTypeTime();
|
| 349 |
+
|
| 350 |
+
$timeStr = Mage::helper('logging/log')->udate('H:i:s.u');
|
| 351 |
+
|
| 352 |
+
$message = '';
|
| 353 |
+
if (!$this->getData()) {
|
| 354 |
+
$message = $timeStr;
|
| 355 |
+
} else {
|
| 356 |
+
$message = $this->getData().' @ '.$timeStr;
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
+
$this->setMessage($message);
|
| 360 |
+
|
| 361 |
+
return $this;
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
/**
|
| 365 |
* Create log entry
|
| 366 |
*/
|
| 377 |
// last usable backtrace
|
| 378 |
$trace = reset($backtrace);
|
| 379 |
$trace = next($backtrace);
|
| 380 |
+
|
| 381 |
// Class
|
| 382 |
if (array_key_exists('class', $trace)) {
|
| 383 |
$this->getLog()
|
| 399 |
->setMethod($method);
|
| 400 |
}
|
| 401 |
|
| 402 |
+
// Data for Backtrace
|
| 403 |
+
$this->getLog()
|
| 404 |
+
->setTrace( $this->_trace() );
|
| 405 |
+
|
| 406 |
+
|
| 407 |
$errors = $this->getLog()->validate();
|
| 408 |
|
| 409 |
if (!is_array($errors)) {
|
| 420 |
$id = $this->getLog()->getId();
|
| 421 |
|
| 422 |
if ($id) {
|
| 423 |
+
|
| 424 |
+
// Check if info mail has to be sent
|
| 425 |
+
if (Mage::helper('logging/config')->isAllowedToSendMail($this->getLog()->getLogType())) {
|
| 426 |
+
$this->getLog()->sendLogMail();
|
| 427 |
+
}
|
| 428 |
+
|
| 429 |
$this->_logModel->unsetData();
|
| 430 |
return $id;
|
| 431 |
}
|
app/code/local/MageDeveloper/Logging/Helper/Log.php
CHANGED
|
@@ -11,7 +11,56 @@
|
|
| 11 |
|
| 12 |
class MageDeveloper_Logging_Helper_Log extends Mage_Core_Helper_Abstract
|
| 13 |
{
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
/**
|
| 16 |
* Get the next found log entry id
|
| 17 |
*
|
| 11 |
|
| 12 |
class MageDeveloper_Logging_Helper_Log extends Mage_Core_Helper_Abstract
|
| 13 |
{
|
| 14 |
+
/**
|
| 15 |
+
* Get a current timestamp
|
| 16 |
+
*
|
| 17 |
+
* @return timestamp
|
| 18 |
+
*/
|
| 19 |
+
public function now()
|
| 20 |
+
{
|
| 21 |
+
return Mage::getModel('core/date')->timestamp( time() );
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* Create timestamp from microtime
|
| 26 |
+
*
|
| 27 |
+
* @return string
|
| 28 |
+
*/
|
| 29 |
+
public function udate($format, $utimestamp = null)
|
| 30 |
+
{
|
| 31 |
+
if (is_null($utimestamp))
|
| 32 |
+
$utimestamp = microtime(true);
|
| 33 |
+
|
| 34 |
+
$timestamp = floor($utimestamp);
|
| 35 |
+
$milliseconds = round(($utimestamp - $timestamp) * 1000000);
|
| 36 |
+
|
| 37 |
+
return date(preg_replace('`(?<!\\\\)u`', $milliseconds, $format), $timestamp);
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
/**
|
| 41 |
+
* Get a timestamp with milliseconds
|
| 42 |
+
*
|
| 43 |
+
* @return string
|
| 44 |
+
*/
|
| 45 |
+
public function timestamp()
|
| 46 |
+
{
|
| 47 |
+
$timestamp = $this->now();
|
| 48 |
+
$timeStr = Mage::helper('core')->formatTime($timestamp, 'long', true);
|
| 49 |
+
|
| 50 |
+
return utf8_decode($timeStr);
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
/**
|
| 54 |
+
* Get a formated timestamp
|
| 55 |
+
*
|
| 56 |
+
* @return string
|
| 57 |
+
*/
|
| 58 |
+
public function getFormatedTimestamp($format = 'long', $includeDate = true)
|
| 59 |
+
{
|
| 60 |
+
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
|
| 64 |
/**
|
| 65 |
* Get the next found log entry id
|
| 66 |
*
|
app/code/local/MageDeveloper/Logging/Helper/Logtype.php
CHANGED
|
@@ -34,12 +34,30 @@ class MageDeveloper_Logging_Helper_Logtype extends MageDeveloper_Logging_Helper_
|
|
| 34 |
return Mage::helper('logging')->__('WARNING');
|
| 35 |
case MageDeveloper_Logging_Model_Log::LOG_TYPE_ERROR:
|
| 36 |
return Mage::helper('logging')->__('ERROR');
|
|
|
|
|
|
|
| 37 |
case MageDeveloper_Logging_Model_Log::LOG_TYPE_NOT_SET:
|
| 38 |
default:
|
| 39 |
return '';
|
| 40 |
}
|
| 41 |
}
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
/**
|
| 44 |
* Get the complete log type style from
|
| 45 |
* a given log type
|
|
@@ -95,6 +113,12 @@ class MageDeveloper_Logging_Helper_Logtype extends MageDeveloper_Logging_Helper_
|
|
| 95 |
$this->setStyle('color', '#cf1515');
|
| 96 |
$this->setStyle('border', '1px solid #cf1515');
|
| 97 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
case MageDeveloper_Logging_Model_Log::LOG_TYPE_NOT_SET:
|
| 100 |
default:
|
| 34 |
return Mage::helper('logging')->__('WARNING');
|
| 35 |
case MageDeveloper_Logging_Model_Log::LOG_TYPE_ERROR:
|
| 36 |
return Mage::helper('logging')->__('ERROR');
|
| 37 |
+
case MageDeveloper_Logging_Model_Log::LOG_TYPE_TIME:
|
| 38 |
+
return Mage::helper('logging')->__('TIME');
|
| 39 |
case MageDeveloper_Logging_Model_Log::LOG_TYPE_NOT_SET:
|
| 40 |
default:
|
| 41 |
return '';
|
| 42 |
}
|
| 43 |
}
|
| 44 |
|
| 45 |
+
/**
|
| 46 |
+
* Get all possible log types
|
| 47 |
+
*
|
| 48 |
+
* @return array
|
| 49 |
+
*/
|
| 50 |
+
public function getLogTypes()
|
| 51 |
+
{
|
| 52 |
+
return array(
|
| 53 |
+
MageDeveloper_Logging_Model_Log::LOG_TYPE_OK => Mage::helper('logging')->__('OK'),
|
| 54 |
+
MageDeveloper_Logging_Model_Log::LOG_TYPE_INFO => Mage::helper('logging')->__('INFO'),
|
| 55 |
+
MageDeveloper_Logging_Model_Log::LOG_TYPE_WARNING => Mage::helper('logging')->__('WARNING'),
|
| 56 |
+
MageDeveloper_Logging_Model_Log::LOG_TYPE_ERROR => Mage::helper('logging')->__('ERROR'),
|
| 57 |
+
MageDeveloper_Logging_Model_Log::LOG_TYPE_TIME => Mage::helper('logging')->__('TIME'),
|
| 58 |
+
);
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
/**
|
| 62 |
* Get the complete log type style from
|
| 63 |
* a given log type
|
| 113 |
$this->setStyle('color', '#cf1515');
|
| 114 |
$this->setStyle('border', '1px solid #cf1515');
|
| 115 |
break;
|
| 116 |
+
|
| 117 |
+
case MageDeveloper_Logging_Model_Log::LOG_TYPE_TIME:
|
| 118 |
+
$this->setStyle('background-color','#FEEADA');
|
| 119 |
+
$this->setStyle('color','#E36A07');
|
| 120 |
+
$this->setStyle('border','1px solid #F87408');
|
| 121 |
+
break;
|
| 122 |
|
| 123 |
case MageDeveloper_Logging_Model_Log::LOG_TYPE_NOT_SET:
|
| 124 |
default:
|
app/code/local/MageDeveloper/Logging/Model/Log.php
CHANGED
|
@@ -16,6 +16,7 @@ class MageDeveloper_Logging_Model_Log extends Mage_Core_Model_Abstract
|
|
| 16 |
const LOG_TYPE_INFO = 2;
|
| 17 |
const LOG_TYPE_WARNING = 3;
|
| 18 |
const LOG_TYPE_ERROR = 4;
|
|
|
|
| 19 |
|
| 20 |
/**
|
| 21 |
* _construct
|
|
@@ -58,6 +59,62 @@ class MageDeveloper_Logging_Model_Log extends Mage_Core_Model_Abstract
|
|
| 58 |
return $helper->getLogTypeStyle($type);
|
| 59 |
}
|
| 60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
/**
|
| 62 |
* Get a formated timestamp
|
| 63 |
*
|
|
@@ -67,6 +124,22 @@ class MageDeveloper_Logging_Model_Log extends Mage_Core_Model_Abstract
|
|
| 67 |
{
|
| 68 |
return Mage::helper('core')->formatTime($this->getTimestamp(), $format, $includeDate);
|
| 69 |
}
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
}
|
| 16 |
const LOG_TYPE_INFO = 2;
|
| 17 |
const LOG_TYPE_WARNING = 3;
|
| 18 |
const LOG_TYPE_ERROR = 4;
|
| 19 |
+
const LOG_TYPE_TIME = 5;
|
| 20 |
|
| 21 |
/**
|
| 22 |
* _construct
|
| 59 |
return $helper->getLogTypeStyle($type);
|
| 60 |
}
|
| 61 |
|
| 62 |
+
/**
|
| 63 |
+
* Send an information mail about the log contents
|
| 64 |
+
*
|
| 65 |
+
* @return bool
|
| 66 |
+
*/
|
| 67 |
+
public function sendLogMail($storeId = '0')
|
| 68 |
+
{
|
| 69 |
+
// Helper
|
| 70 |
+
$configHelper = Mage::helper('logging/config');
|
| 71 |
+
|
| 72 |
+
// Template Id for the logging event information mail
|
| 73 |
+
$templateId = $configHelper->getMailTemplateId();
|
| 74 |
+
|
| 75 |
+
if (!$templateId) {
|
| 76 |
+
return false;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
if (!$storeId) {
|
| 80 |
+
$storeId = $this->_getWebsiteStoreId($this->getSendemailStoreId());
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
/** @var $mailer Mage_Core_Model_Email_Template_Mailer */
|
| 84 |
+
$mailer = Mage::getModel('core/email_template_mailer');
|
| 85 |
+
|
| 86 |
+
$emailInfo = Mage::getModel('core/email_info');
|
| 87 |
+
$recipients = $configHelper->getRecipients();
|
| 88 |
+
foreach ($recipients as $key=>$_recipient) {
|
| 89 |
+
$emailInfo->addTo($_recipient);
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
$mailer->setSender( array('name' => $configHelper->getSenderName(),
|
| 93 |
+
'email' => $configHelper->getSenderMail()
|
| 94 |
+
)
|
| 95 |
+
);
|
| 96 |
+
|
| 97 |
+
$mailer->setStoreId($storeId);
|
| 98 |
+
$mailer->setTemplateId($templateId);
|
| 99 |
+
|
| 100 |
+
// Template Params
|
| 101 |
+
$params = array(
|
| 102 |
+
'log' => $this,
|
| 103 |
+
'type' => Mage::helper('logging/logtype')->getLogTypeString($this->getLogType()),
|
| 104 |
+
'type_html' => Mage::helper('logging/logtype')->getLogTypeStyle($this->getLogType()),
|
| 105 |
+
'timestamp' => $this->getFormatedTimestamp(),
|
| 106 |
+
);
|
| 107 |
+
|
| 108 |
+
$mailer->setTemplateParams($params);
|
| 109 |
+
|
| 110 |
+
$mailer->addEmailInfo($emailInfo);
|
| 111 |
+
|
| 112 |
+
if ($mailer->send()) {
|
| 113 |
+
return true;
|
| 114 |
+
}
|
| 115 |
+
return false;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
/**
|
| 119 |
* Get a formated timestamp
|
| 120 |
*
|
| 124 |
{
|
| 125 |
return Mage::helper('core')->formatTime($this->getTimestamp(), $format, $includeDate);
|
| 126 |
}
|
| 127 |
+
|
| 128 |
+
/**
|
| 129 |
+
* Get either first store ID from a set website or the provided as default
|
| 130 |
+
*
|
| 131 |
+
* @param int|string|null $storeId
|
| 132 |
+
*
|
| 133 |
+
* @return int
|
| 134 |
+
*/
|
| 135 |
+
protected function _getWebsiteStoreId($defaultStoreId = null)
|
| 136 |
+
{
|
| 137 |
+
if ($this->getWebsiteId() != 0 && empty($defaultStoreId)) {
|
| 138 |
+
$storeIds = Mage::app()->getWebsite($this->getWebsiteId())->getStoreIds();
|
| 139 |
+
reset($storeIds);
|
| 140 |
+
$defaultStoreId = current($storeIds);
|
| 141 |
+
}
|
| 142 |
+
return $defaultStoreId;
|
| 143 |
+
}
|
| 144 |
|
| 145 |
}
|
app/code/local/MageDeveloper/Logging/Model/Mysql4/Log/Collection.php
CHANGED
|
@@ -16,4 +16,48 @@ class MageDeveloper_Logging_Model_Mysql4_Log_Collection extends Mage_Core_Model_
|
|
| 16 |
parent::_construct();
|
| 17 |
$this->_init('logging/log');
|
| 18 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
}
|
| 16 |
parent::_construct();
|
| 17 |
$this->_init('logging/log');
|
| 18 |
}
|
| 19 |
+
|
| 20 |
+
/**
|
| 21 |
+
* Add start and enddate to the filter
|
| 22 |
+
*
|
| 23 |
+
* @param string $startdate Startdate to filter
|
| 24 |
+
* @param string $enddate Enddate to filter
|
| 25 |
+
* @return self
|
| 26 |
+
*/
|
| 27 |
+
public function addDateToFilter($startdate, $enddate = null)
|
| 28 |
+
{
|
| 29 |
+
// Handling start date
|
| 30 |
+
$dateStart = date('Y-m-d' . ' 00:00:00', $startdate);
|
| 31 |
+
$this->addFieldToFilter('timestamp', array(array(
|
| 32 |
+
array('date' => true, 'from' => $dateStart),
|
| 33 |
+
array('null' => true)
|
| 34 |
+
), 'left')
|
| 35 |
+
);
|
| 36 |
+
|
| 37 |
+
// Handling possible end date
|
| 38 |
+
if ($enddate !== null) {
|
| 39 |
+
|
| 40 |
+
$dateEnd = date('Y-m-d' . ' 23:59:59', $enddate);
|
| 41 |
+
$this->addFieldToFilter('timestamp', array(array(
|
| 42 |
+
array('date' => true, 'to' => $enddate),
|
| 43 |
+
array('null' => true)
|
| 44 |
+
), 'left')
|
| 45 |
+
);
|
| 46 |
+
}
|
| 47 |
+
return $this;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
/**
|
| 51 |
+
* Add time filter for today
|
| 52 |
+
*
|
| 53 |
+
* @return self
|
| 54 |
+
*/
|
| 55 |
+
public function addTodayFilter()
|
| 56 |
+
{
|
| 57 |
+
$currentTimestamp = Mage::helper('logging/log')->now();
|
| 58 |
+
|
| 59 |
+
$this->addDateToFilter($currentTimestamp, $currentTimestamp);
|
| 60 |
+
return $this;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
}
|
app/code/local/MageDeveloper/Logging/Model/Source/Types.php
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* MageDeveloper Logging Module
|
| 4 |
+
* ----------------------------
|
| 5 |
+
*
|
| 6 |
+
* @category Mage
|
| 7 |
+
* @package MageDeveloper_Logging
|
| 8 |
+
* @copyright Magento Developers / magedeveloper.de
|
| 9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
class MageDeveloper_Logging_Model_Source_Types extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
|
| 13 |
+
{
|
| 14 |
+
/**
|
| 15 |
+
* Options
|
| 16 |
+
* @var array
|
| 17 |
+
*/
|
| 18 |
+
protected $_options;
|
| 19 |
+
|
| 20 |
+
/**
|
| 21 |
+
* Get all logtypes
|
| 22 |
+
*
|
| 23 |
+
* @return array
|
| 24 |
+
*/
|
| 25 |
+
private function _getTypes()
|
| 26 |
+
{
|
| 27 |
+
return Mage::helper('logging/logtype')->getLogTypes();
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* Get all available options
|
| 32 |
+
*
|
| 33 |
+
* @return array
|
| 34 |
+
*/
|
| 35 |
+
public function getAllOptions()
|
| 36 |
+
{
|
| 37 |
+
if (is_null($this->_options)) {
|
| 38 |
+
|
| 39 |
+
$types = $this->_getTypes();
|
| 40 |
+
|
| 41 |
+
$options = array();
|
| 42 |
+
foreach ($types as $_val=>$_text) {
|
| 43 |
+
|
| 44 |
+
$option = array();
|
| 45 |
+
|
| 46 |
+
$option['label'] = $_text;
|
| 47 |
+
$option['value'] = $_val;
|
| 48 |
+
|
| 49 |
+
$options[] = $option;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
$this->_options = $options;
|
| 53 |
+
}
|
| 54 |
+
return $this->_options;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
/**
|
| 58 |
+
* Get all options to an option array
|
| 59 |
+
*
|
| 60 |
+
* @return array
|
| 61 |
+
*/
|
| 62 |
+
public function toOptionArray()
|
| 63 |
+
{
|
| 64 |
+
return $this->getAllOptions();
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
}
|
app/code/local/MageDeveloper/Logging/controllers/Adminhtml/LoggingController.php
CHANGED
|
@@ -62,6 +62,24 @@ class MageDeveloper_Logging_Adminhtml_LoggingController extends Mage_Adminhtml_C
|
|
| 62 |
$this->renderLayout();
|
| 63 |
}
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
/**
|
| 66 |
* deleteAction
|
| 67 |
*/
|
|
@@ -136,11 +154,5 @@ class MageDeveloper_Logging_Adminhtml_LoggingController extends Mage_Adminhtml_C
|
|
| 136 |
$this->_redirect('*/*/index');
|
| 137 |
}
|
| 138 |
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
}
|
| 146 |
|
| 62 |
$this->renderLayout();
|
| 63 |
}
|
| 64 |
|
| 65 |
+
/**
|
| 66 |
+
* mailAction
|
| 67 |
+
* Mails details of an logging entry
|
| 68 |
+
* and redirects to the detail view
|
| 69 |
+
*/
|
| 70 |
+
public function mailAction()
|
| 71 |
+
{
|
| 72 |
+
$log = $this->_initLog();
|
| 73 |
+
|
| 74 |
+
if (!$log->getId()) {
|
| 75 |
+
$this->_getSession()->addError(Mage::helper('logging')->__('This log no longer exists.'));
|
| 76 |
+
$this->_redirect('*/*/');
|
| 77 |
+
return;
|
| 78 |
+
}
|
| 79 |
+
$log->sendLogMail();
|
| 80 |
+
$this->_redirect('*/*/view', array('id' => $this->getRequest()->getParam('id')));
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
/**
|
| 84 |
* deleteAction
|
| 85 |
*/
|
| 154 |
$this->_redirect('*/*/index');
|
| 155 |
}
|
| 156 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
}
|
| 158 |
|
app/code/local/MageDeveloper/Logging/etc/config.xml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
<config>
|
| 3 |
<modules>
|
| 4 |
<MageDeveloper_Logging>
|
| 5 |
-
<version>1.
|
| 6 |
</MageDeveloper_Logging>
|
| 7 |
</modules>
|
| 8 |
<global>
|
|
@@ -81,6 +81,25 @@
|
|
| 81 |
</logging>
|
| 82 |
</updates>
|
| 83 |
</layout>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
</adminhtml>
|
| 85 |
|
| 86 |
</config>
|
| 2 |
<config>
|
| 3 |
<modules>
|
| 4 |
<MageDeveloper_Logging>
|
| 5 |
+
<version>1.3.0</version>
|
| 6 |
</MageDeveloper_Logging>
|
| 7 |
</modules>
|
| 8 |
<global>
|
| 81 |
</logging>
|
| 82 |
</updates>
|
| 83 |
</layout>
|
| 84 |
+
<acl>
|
| 85 |
+
<resources>
|
| 86 |
+
<admin>
|
| 87 |
+
<children>
|
| 88 |
+
<system>
|
| 89 |
+
<children>
|
| 90 |
+
<config>
|
| 91 |
+
<children>
|
| 92 |
+
<logging>
|
| 93 |
+
<title>Logging Settings</title>
|
| 94 |
+
</logging>
|
| 95 |
+
</children>
|
| 96 |
+
</config>
|
| 97 |
+
</children>
|
| 98 |
+
</system>
|
| 99 |
+
</children>
|
| 100 |
+
</admin>
|
| 101 |
+
</resources>
|
| 102 |
+
</acl>
|
| 103 |
</adminhtml>
|
| 104 |
|
| 105 |
</config>
|
app/code/local/MageDeveloper/Logging/etc/system.xml
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<sections>
|
| 4 |
+
<logging translate="label" module="logging">
|
| 5 |
+
<tab>advanced</tab>
|
| 6 |
+
<label>Logging Settings</label>
|
| 7 |
+
<frontend_type>text</frontend_type>
|
| 8 |
+
<sort_order>5500</sort_order>
|
| 9 |
+
<show_in_default>1</show_in_default>
|
| 10 |
+
<show_in_website>1</show_in_website>
|
| 11 |
+
<show_in_store>1</show_in_store>
|
| 12 |
+
<groups>
|
| 13 |
+
<mail_settings translate="label" module="logging">
|
| 14 |
+
<label>Mail Settings</label>
|
| 15 |
+
<frontend_type>text</frontend_type>
|
| 16 |
+
<sort_order>0</sort_order>
|
| 17 |
+
<show_in_default>1</show_in_default>
|
| 18 |
+
<show_in_website>1</show_in_website>
|
| 19 |
+
<show_in_store>1</show_in_store>
|
| 20 |
+
<fields>
|
| 21 |
+
<enable_mails translate="label">
|
| 22 |
+
<label>Enable Mails</label>
|
| 23 |
+
<frontend_type>select</frontend_type>
|
| 24 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 25 |
+
<comment>Enable this setting if you want to send the mails on log events</comment>
|
| 26 |
+
<sort_order>0</sort_order>
|
| 27 |
+
<show_in_default>1</show_in_default>
|
| 28 |
+
<show_in_website>1</show_in_website>
|
| 29 |
+
<show_in_store>1</show_in_store>
|
| 30 |
+
</enable_mails>
|
| 31 |
+
<typeselect translate="label">
|
| 32 |
+
<label>Send mails on specific logtype</label>
|
| 33 |
+
<frontend_type>multiselect</frontend_type>
|
| 34 |
+
<source_model>logging/source_types</source_model>
|
| 35 |
+
<sort_order>50</sort_order>
|
| 36 |
+
<show_in_default>1</show_in_default>
|
| 37 |
+
<show_in_website>1</show_in_website>
|
| 38 |
+
<show_in_store>1</show_in_store>
|
| 39 |
+
</typeselect>
|
| 40 |
+
<template translate="label">
|
| 41 |
+
<label>E-Mail Template for mail</label>
|
| 42 |
+
<frontend_type>select</frontend_type>
|
| 43 |
+
<source_model>adminhtml/system_config_source_email_template</source_model>
|
| 44 |
+
<sort_order>100</sort_order>
|
| 45 |
+
<show_in_default>1</show_in_default>
|
| 46 |
+
<show_in_website>1</show_in_website>
|
| 47 |
+
<show_in_store>1</show_in_store>
|
| 48 |
+
</template>
|
| 49 |
+
<sender translate="label">
|
| 50 |
+
<label>Sender for the mail</label>
|
| 51 |
+
<frontend_type>select</frontend_type>
|
| 52 |
+
<source_model>adminhtml/system_config_source_email_identity</source_model>
|
| 53 |
+
<sort_order>150</sort_order>
|
| 54 |
+
<show_in_default>1</show_in_default>
|
| 55 |
+
<show_in_website>1</show_in_website>
|
| 56 |
+
<show_in_store>1</show_in_store>
|
| 57 |
+
</sender>
|
| 58 |
+
<recipients translate="label">
|
| 59 |
+
<label>Mail recipients</label>
|
| 60 |
+
<comment>Please enter the mail recipients, separated by semicolon (e.g. mail@you.com;mail@him.co.uk;mail@her.tv)</comment>
|
| 61 |
+
<frontend_type>text</frontend_type>
|
| 62 |
+
<sort_order>200</sort_order>
|
| 63 |
+
<show_in_default>1</show_in_default>
|
| 64 |
+
<show_in_website>1</show_in_website>
|
| 65 |
+
<show_in_store>1</show_in_store>
|
| 66 |
+
</recipients>
|
| 67 |
+
</fields>
|
| 68 |
+
</mail_settings>
|
| 69 |
+
</groups>
|
| 70 |
+
</logging>
|
| 71 |
+
</sections>
|
| 72 |
+
</config>
|
app/code/local/MageDeveloper/Logging/sql/magedeveloper_logging_setup/mysql4-upgrade-1.2.0-1.3.0.php
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* MageDeveloper Logging Module
|
| 4 |
+
* ----------------------------
|
| 5 |
+
*
|
| 6 |
+
* @category Mage
|
| 7 |
+
* @package MageDeveloper_Logging
|
| 8 |
+
* @copyright Magento Developers / magedeveloper.de
|
| 9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
$installer = $this;
|
| 13 |
+
$installer->startSetup();
|
| 14 |
+
|
| 15 |
+
$template =
|
| 16 |
+
'
|
| 17 |
+
<div style="font:11px/1.35em Verdana, Arial, Helvetica, sans-serif;">
|
| 18 |
+
<table cellspacing="0" cellpadding="0" border="0" width="98%" style="margin-top:10px; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; margin-bottom:10px;">
|
| 19 |
+
<tr>
|
| 20 |
+
<td align="center" valign="top">
|
| 21 |
+
<table cellspacing="0" cellpadding="0" border="0" width="100%">
|
| 22 |
+
<tr>
|
| 23 |
+
<td valign="top">
|
| 24 |
+
<p>
|
| 25 |
+
{{var type_html}}
|
| 26 |
+
<br />
|
| 27 |
+
<strong>Log Event Information:</strong>
|
| 28 |
+
<br /><br />
|
| 29 |
+
<br />
|
| 30 |
+
Id: {{var log.entity_id}}
|
| 31 |
+
<br />
|
| 32 |
+
Timestamp: {{var timestamp}}
|
| 33 |
+
<br />
|
| 34 |
+
Method: {{var log.method}}
|
| 35 |
+
<br />
|
| 36 |
+
Class: {{var log.class}}
|
| 37 |
+
<hr />
|
| 38 |
+
Data:
|
| 39 |
+
<pre>
|
| 40 |
+
<div style="border:1px solid #c0c0c0;margin-top:5px;padding:5px;width:100%;font-family:Courier, Courier New;font-size:11px; background-color:#ffffff">{{var log.output}}</div>
|
| 41 |
+
</pre>
|
| 42 |
+
<hr />
|
| 43 |
+
Backtrace:
|
| 44 |
+
<pre>
|
| 45 |
+
<div style="border:1px solid #c0c0c0;margin-top:5px;padding:5px;width:100%;font-family:Courier, Courier New;font-size:11px; background-color:#ffffff">{{var log.trace}}</div>
|
| 46 |
+
</pre>
|
| 47 |
+
</p>
|
| 48 |
+
</td>
|
| 49 |
+
</tr>
|
| 50 |
+
</table>
|
| 51 |
+
</td>
|
| 52 |
+
</tr>
|
| 53 |
+
</table>
|
| 54 |
+
</div>
|
| 55 |
+
';
|
| 56 |
+
|
| 57 |
+
$installer->run("
|
| 58 |
+
INSERT IGNORE INTO {$this->getTable('core_email_template')}
|
| 59 |
+
(
|
| 60 |
+
`template_code`,
|
| 61 |
+
`template_text`,
|
| 62 |
+
`template_type`,
|
| 63 |
+
`template_subject`,
|
| 64 |
+
`template_sender_name`,
|
| 65 |
+
`template_sender_email`,
|
| 66 |
+
`added_at`,
|
| 67 |
+
`modified_at`
|
| 68 |
+
)
|
| 69 |
+
VALUES
|
| 70 |
+
(
|
| 71 |
+
'Log Event Mail Template (html)',
|
| 72 |
+
'".$template."',
|
| 73 |
+
".Mage_Core_Model_Template::TYPE_HTML.",
|
| 74 |
+
'".Mage::helper('logging')->__('Log Event Information')."',
|
| 75 |
+
NULL,
|
| 76 |
+
NULL,
|
| 77 |
+
NOW(),
|
| 78 |
+
NOW()
|
| 79 |
+
);
|
| 80 |
+
");
|
| 81 |
+
|
| 82 |
+
$installer->run("
|
| 83 |
+
ALTER TABLE {$installer->getTable('log_entity')} ADD `trace` LONGTEXT NOT NULL AFTER `output`
|
| 84 |
+
");
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>LoggingHelper</name>
|
| 4 |
-
<version>1.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://www.gnu.org/licenses/gpl-3.0.html">GPL</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -27,11 +27,11 @@ Mage::helper('logging')
|
|
| 27 |
Types: NOT_SET,OK, INFO, WARNING, ERROR
|
| 28 |

|
| 29 |
</description>
|
| 30 |
-
<notes>New featues: Detail View
|
| 31 |
<authors><author><name>Bastian Zagar</name><user>aggy</user><email>zagar@aixdesign.net</email></author></authors>
|
| 32 |
-
<date>2013-
|
| 33 |
-
<time>
|
| 34 |
-
<contents><target name="magelocal"><dir name="MageDeveloper"><dir name="Logging"><dir name="Block"><dir name="Adminhtml"><dir name="Logging"><dir name="Compare"><file name="Form.php" hash="a0ae1bb3717b1f06cec4db8a05fdded4"/></dir><file name="Compare.php" hash="10227570bf37eef3a4e4a0ec32dc409e"/><file name="Grid.php" hash="
|
| 35 |
<compatible/>
|
| 36 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 37 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>LoggingHelper</name>
|
| 4 |
+
<version>1.3.0</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://www.gnu.org/licenses/gpl-3.0.html">GPL</license>
|
| 7 |
<channel>community</channel>
|
| 27 |
Types: NOT_SET,OK, INFO, WARNING, ERROR
|
| 28 |

|
| 29 |
</description>
|
| 30 |
+
<notes>New featues: Automatically E-Mail Logs with specified type; Send by Mail - Button in Detail View.</notes>
|
| 31 |
<authors><author><name>Bastian Zagar</name><user>aggy</user><email>zagar@aixdesign.net</email></author></authors>
|
| 32 |
+
<date>2013-05-13</date>
|
| 33 |
+
<time>08:46:23</time>
|
| 34 |
+
<contents><target name="magelocal"><dir name="MageDeveloper"><dir name="Logging"><dir name="Block"><dir name="Adminhtml"><dir name="Logging"><dir name="Compare"><file name="Form.php" hash="a0ae1bb3717b1f06cec4db8a05fdded4"/></dir><file name="Compare.php" hash="10227570bf37eef3a4e4a0ec32dc409e"/><file name="Grid.php" hash="4919b4386455f0d624d7568a5743fc71"/><dir name="Renderer"><file name="LogType.php" hash="6346c5cf00ef69127531ffde685bd663"/><file name="Pre.php" hash="e3a291fb6a0dab8d6c66ebc83dadd332"/></dir><dir name="View"><file name="Form.php" hash="e480045256af626bd22b30d1f48669a8"/></dir><file name="View.php" hash="0e2a75a088ab83ca0cebab692a69bcb9"/></dir><file name="Logging.php" hash="da1498c795ad6b81c0cb7bd81314a794"/></dir></dir><dir name="Helper"><file name="Config.php" hash="c71db7aebdf0728d0ab1703e07437416"/><file name="Data.php" hash="109688e8791f35bd970d9f7c8bc7d277"/><file name="Log.php" hash="4124150bf75b42c4171b699cd95ac053"/><file name="Logtype.php" hash="c78058c3f9fb8578b08c4f22247b4477"/><file name="Style.php" hash="954c8d14d360081ccb337c062f442010"/></dir><dir name="Lib"><dir name="Varien"><dir name="Data"><dir name="Form"><dir name="Element"><file name="LogType.php" hash="34eb3ac1ff35926f75d8ce6d10c233ff"/><file name="Output.php" hash="0b1b6341b17cc0cc63c09fca2493ec8d"/></dir></dir></dir></dir></dir><dir name="Model"><file name="Log.php" hash="5bb98cd2eebbca1724963558a392d417"/><dir name="Mysql4"><dir name="Log"><file name="Collection.php" hash="21ddd44943570cae67e2d51027f731a3"/></dir><file name="Log.php" hash="9160734fd0857439968e2236963bcca7"/></dir><dir name="Source"><file name="Types.php" hash="ee8f940ae43688f71f5e4de54d2ed885"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="LoggingController.php" hash="dc4b78e6996eee2d7fc9464c4edfaf31"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="b861cc7eedd55f1971357a8fe3985a42"/><file name="config.xml" hash="e7a27c59bcb2039340b3981cfb5956d3"/><file name="system.xml" hash="ad15f5ff8a2964f6960324b9dd083877"/></dir><dir name="sql"><dir name="magedeveloper_logging_setup"><file name="mysql4-install-1.0.0.php" hash="1fcda8eb4bc11cf3b126db7cba778f42"/><file name="mysql4-upgrade-1.2.0-1.3.0.php" hash="db4e28ec147198fb49c441ee82fe60b0"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="MageDeveloper_Logging.xml" hash="5e4a4a97b123a5161e121c7bcd70038d"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="logging.xml" hash="6960122a9f7e94f35d5ef90ef22abab0"/></dir><dir name="template"><dir name="logging"><file name="compare.phtml" hash="273e94ea7c5a96978fcb74428699f446"/></dir></dir></dir></dir></dir></target></contents>
|
| 35 |
<compatible/>
|
| 36 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 37 |
</package>
|
