Version Notes
New featues: Detail View, Compare
Download this release
Release Info
Developer | Bastian Zagar |
Extension | LoggingHelper |
Version | 1.2.0 |
Comparing to | |
See all releases |
Code changes from version 1.1.1 to 1.2.0
- app/code/local/MageDeveloper/Logging/Block/Adminhtml/Logging/Compare.php +38 -0
- app/code/local/MageDeveloper/Logging/Block/Adminhtml/Logging/Compare/Form.php +67 -0
- app/code/local/MageDeveloper/Logging/Block/Adminhtml/Logging/Grid.php +33 -2
- app/code/local/MageDeveloper/Logging/Block/Adminhtml/Logging/Renderer/LogType.php +7 -69
- app/code/local/MageDeveloper/Logging/Block/Adminhtml/Logging/Renderer/Pre.php +5 -1
- app/code/local/MageDeveloper/Logging/Block/Adminhtml/Logging/View.php +101 -0
- app/code/local/MageDeveloper/Logging/Block/Adminhtml/Logging/View/Form.php +85 -0
- app/code/local/MageDeveloper/Logging/Helper/Data.php +44 -0
- app/code/local/MageDeveloper/Logging/Helper/Log.php +90 -0
- app/code/local/MageDeveloper/Logging/Helper/Logtype.php +108 -0
- app/code/local/MageDeveloper/Logging/Helper/Style.php +77 -0
- app/code/local/MageDeveloper/Logging/Lib/Varien/Data/Form/Element/LogType.php +41 -0
- app/code/local/MageDeveloper/Logging/Lib/Varien/Data/Form/Element/Output.php +43 -0
- app/code/local/MageDeveloper/Logging/Model/Log.php +22 -0
- app/code/local/MageDeveloper/Logging/controllers/Adminhtml/LoggingController.php +86 -0
- app/code/local/MageDeveloper/Logging/etc/config.xml +1 -2
- app/design/adminhtml/default/default/layout/logging.xml +13 -1
- app/design/adminhtml/default/default/template/logging/compare.phtml +82 -0
- package.xml +7 -10
app/code/local/MageDeveloper/Logging/Block/Adminhtml/Logging/Compare.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Block_Adminhtml_Logging_Compare extends Mage_Adminhtml_Block_Widget_Form_Container
|
13 |
+
{
|
14 |
+
public function __construct()
|
15 |
+
{
|
16 |
+
$this->_objectId = 'id';
|
17 |
+
$this->_controller = 'adminhtml_logging';
|
18 |
+
$this->_mode = 'compare';
|
19 |
+
$this->_blockGroup = 'logging';
|
20 |
+
|
21 |
+
parent::__construct();
|
22 |
+
|
23 |
+
$this->removeButton('delete');
|
24 |
+
$this->removeButton('reset');
|
25 |
+
$this->removeButton('save');
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Get header text
|
30 |
+
*
|
31 |
+
* @return string
|
32 |
+
*/
|
33 |
+
public function getHeaderText()
|
34 |
+
{
|
35 |
+
return Mage::helper('logging')->__('Compare Log Entries');
|
36 |
+
}
|
37 |
+
|
38 |
+
}
|
app/code/local/MageDeveloper/Logging/Block/Adminhtml/Logging/Compare/Form.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Block_Adminhtml_Logging_Compare_Form extends Mage_Adminhtml_Block_Widget_Form
|
13 |
+
{
|
14 |
+
|
15 |
+
protected $collection;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Additional buttons on category page
|
19 |
+
*
|
20 |
+
* @var array
|
21 |
+
*/
|
22 |
+
protected $_additionalButtons = array();
|
23 |
+
|
24 |
+
public function __construct()
|
25 |
+
{
|
26 |
+
parent::__construct();
|
27 |
+
$this->setTemplate('logging/compare.phtml');
|
28 |
+
}
|
29 |
+
|
30 |
+
|
31 |
+
protected function _prepareLayout()
|
32 |
+
{
|
33 |
+
return parent::_prepareLayout();
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getIds()
|
37 |
+
{
|
38 |
+
if (!$this->getData('log_ids')) {
|
39 |
+
$this->setData('log_ids', Mage::registry('log_ids'));
|
40 |
+
}
|
41 |
+
return $this->getData('log_ids');
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Get all chosen log entry models as data collection
|
46 |
+
*
|
47 |
+
* @return Varien_Data_Collection
|
48 |
+
*/
|
49 |
+
public function getLogEntries()
|
50 |
+
{
|
51 |
+
$collection = new Varien_Data_Collection();
|
52 |
+
|
53 |
+
foreach ($this->getIds() as $_id) {
|
54 |
+
try {
|
55 |
+
$model = Mage::getModel('logging/log')->load($_id);
|
56 |
+
$collection->addItem($model);
|
57 |
+
|
58 |
+
} catch (Exception $e) {
|
59 |
+
$this->_getSession()->addError(Mage::helper('logging')->__('Could not load log entry with id %s', $_id));
|
60 |
+
}
|
61 |
+
}
|
62 |
+
return $collection;
|
63 |
+
}
|
64 |
+
|
65 |
+
|
66 |
+
}
|
67 |
+
|
app/code/local/MageDeveloper/Logging/Block/Adminhtml/Logging/Grid.php
CHANGED
@@ -78,7 +78,7 @@ class MageDeveloper_Logging_Block_Adminhtml_Logging_Grid extends Mage_Adminhtml_
|
|
78 |
'width' => '120px',
|
79 |
'index' => 'method',
|
80 |
));
|
81 |
-
|
82 |
$this->addColumn('output', array(
|
83 |
'header' => Mage::helper('logging')->__('Data'),
|
84 |
'align' => 'left',
|
@@ -86,6 +86,27 @@ class MageDeveloper_Logging_Block_Adminhtml_Logging_Grid extends Mage_Adminhtml_
|
|
86 |
'index' => 'output',
|
87 |
'renderer' => 'MageDeveloper_Logging_Block_Adminhtml_Logging_Renderer_Pre',
|
88 |
));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
return parent::_prepareColumns();
|
90 |
}
|
91 |
|
@@ -100,14 +121,24 @@ class MageDeveloper_Logging_Block_Adminhtml_Logging_Grid extends Mage_Adminhtml_
|
|
100 |
'url' => $this->getUrl('*/*/massDelete'),
|
101 |
'confirm' => Mage::helper('logging')->__('Are you sure?')
|
102 |
));
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
return $this;
|
105 |
}
|
106 |
|
107 |
|
|
|
|
|
|
|
|
|
|
|
108 |
public function getRowUrl($row)
|
109 |
{
|
110 |
-
return '';
|
111 |
}
|
112 |
|
113 |
}
|
78 |
'width' => '120px',
|
79 |
'index' => 'method',
|
80 |
));
|
81 |
+
|
82 |
$this->addColumn('output', array(
|
83 |
'header' => Mage::helper('logging')->__('Data'),
|
84 |
'align' => 'left',
|
86 |
'index' => 'output',
|
87 |
'renderer' => 'MageDeveloper_Logging_Block_Adminhtml_Logging_Renderer_Pre',
|
88 |
));
|
89 |
+
|
90 |
+
|
91 |
+
$this->addColumn('action',
|
92 |
+
array(
|
93 |
+
'header' => Mage::helper('logging')->__('Action'),
|
94 |
+
'width' => '50',
|
95 |
+
'type' => 'action',
|
96 |
+
'getter' => 'getId',
|
97 |
+
'actions' => array(
|
98 |
+
array(
|
99 |
+
'caption' => Mage::helper('logging')->__('View'),
|
100 |
+
'url' => array('base'=> '*/*/view'),
|
101 |
+
'field' => 'id'
|
102 |
+
)
|
103 |
+
),
|
104 |
+
'filter' => false,
|
105 |
+
'sortable' => false,
|
106 |
+
'index' => 'stores',
|
107 |
+
'is_system' => true,
|
108 |
+
));
|
109 |
+
|
110 |
return parent::_prepareColumns();
|
111 |
}
|
112 |
|
121 |
'url' => $this->getUrl('*/*/massDelete'),
|
122 |
'confirm' => Mage::helper('logging')->__('Are you sure?')
|
123 |
));
|
124 |
+
|
125 |
+
$this->getMassactionBlock()->addItem('compare', array(
|
126 |
+
'label' => Mage::helper('logging')->__('Compare'),
|
127 |
+
'url' => $this->getUrl('*/*/compare')
|
128 |
+
));
|
129 |
|
130 |
return $this;
|
131 |
}
|
132 |
|
133 |
|
134 |
+
/**
|
135 |
+
* Return row url for js event handlers
|
136 |
+
*
|
137 |
+
* @return string
|
138 |
+
*/
|
139 |
public function getRowUrl($row)
|
140 |
{
|
141 |
+
return $this->getUrl('*/*/view', array('id'=>$row->getId()));
|
142 |
}
|
143 |
|
144 |
}
|
app/code/local/MageDeveloper/Logging/Block/Adminhtml/Logging/Renderer/LogType.php
CHANGED
@@ -11,38 +11,13 @@
|
|
11 |
|
12 |
class MageDeveloper_Logging_Block_Adminhtml_Logging_Renderer_LogType extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
13 |
{
|
14 |
-
protected $
|
15 |
|
16 |
|
17 |
public function __construct()
|
18 |
{
|
19 |
parent::__construct();
|
20 |
-
$this->
|
21 |
-
}
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Set a css style
|
25 |
-
*
|
26 |
-
* @param string $style CSS Style Name
|
27 |
-
* @param string $vlaue CSS Style Value
|
28 |
-
* @return void
|
29 |
-
*/
|
30 |
-
public function setStyle($style, $value)
|
31 |
-
{
|
32 |
-
$this->_styles[] = $style.':'.$value;
|
33 |
-
return;
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Get css styles
|
38 |
-
*
|
39 |
-
* @return string
|
40 |
-
*/
|
41 |
-
public function getStyles()
|
42 |
-
{
|
43 |
-
$string = implode(';',$this->_styles);
|
44 |
-
$this->_styles = array();
|
45 |
-
return $string;
|
46 |
}
|
47 |
|
48 |
/**
|
@@ -55,49 +30,12 @@ class MageDeveloper_Logging_Block_Adminhtml_Logging_Renderer_LogType extends Mag
|
|
55 |
public function render(Varien_Object $row)
|
56 |
{
|
57 |
$rowContent = $row->getData( $this->getColumn()->getIndex() );
|
|
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
$rowContent = Mage::helper('logging')->__('OK');
|
63 |
-
$this->setStyle('background-color', '#c1ffcf');
|
64 |
-
$this->setStyle('color', '#197a52');
|
65 |
-
$this->setStyle('border', '1px solid #197a52');
|
66 |
-
break;
|
67 |
-
|
68 |
-
case MageDeveloper_Logging_Model_Log::LOG_TYPE_INFO:
|
69 |
-
$rowContent = Mage::helper('logging')->__('INFO');
|
70 |
-
$this->setStyle('background-color', '#bdf7ff');
|
71 |
-
$this->setStyle('color', '#1598cf');
|
72 |
-
$this->setStyle('border', '1px solid #1598cf');
|
73 |
-
break;
|
74 |
-
|
75 |
-
case MageDeveloper_Logging_Model_Log::LOG_TYPE_WARNING:
|
76 |
-
$rowContent = Mage::helper('logging')->__('WARNING');
|
77 |
-
$this->setStyle('background-color', '#feffc1');
|
78 |
-
$this->setStyle('color', '#cea915');
|
79 |
-
$this->setStyle('border', '1px solid #cea915');
|
80 |
-
break;
|
81 |
-
|
82 |
-
case MageDeveloper_Logging_Model_Log::LOG_TYPE_ERROR:
|
83 |
-
$rowContent = Mage::helper('logging')->__('ERROR');
|
84 |
-
$this->setStyle('background-color', '#ffc5bd');
|
85 |
-
$this->setStyle('color', '#cf1515');
|
86 |
-
$this->setStyle('border', '1px solid #cf1515');
|
87 |
-
break;
|
88 |
-
|
89 |
-
case MageDeveloper_Logging_Model_Log::LOG_TYPE_NOT_SET:
|
90 |
-
default:
|
91 |
-
$rowContent = '';
|
92 |
-
$this->setStyle('background-color', 'transparent');
|
93 |
-
$this->setStyle('color', '#000000');
|
94 |
-
}
|
95 |
-
|
96 |
-
// General Styles
|
97 |
-
$this->setStyle('font-weight', 'bold');
|
98 |
-
$this->setStyle('margin', '2px');
|
99 |
-
$this->setStyle('padding', '2px');
|
100 |
|
101 |
-
return
|
102 |
}
|
103 |
}
|
11 |
|
12 |
class MageDeveloper_Logging_Block_Adminhtml_Logging_Renderer_LogType extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
13 |
{
|
14 |
+
protected $helper;
|
15 |
|
16 |
|
17 |
public function __construct()
|
18 |
{
|
19 |
parent::__construct();
|
20 |
+
$this->helper = Mage::helper('logging/logtype');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
}
|
22 |
|
23 |
/**
|
30 |
public function render(Varien_Object $row)
|
31 |
{
|
32 |
$rowContent = $row->getData( $this->getColumn()->getIndex() );
|
33 |
+
$logType = (int)$rowContent;
|
34 |
|
35 |
+
$logText = $this->helper->getLogTypeString($logType);
|
36 |
+
// Set log styles
|
37 |
+
$this->helper->setLogTypeStyles($logType);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
+
return $this->helper->getStyledContent($logText);
|
40 |
}
|
41 |
}
|
app/code/local/MageDeveloper/Logging/Block/Adminhtml/Logging/Renderer/Pre.php
CHANGED
@@ -20,7 +20,11 @@ class MageDeveloper_Logging_Block_Adminhtml_Logging_Renderer_Pre extends Mage_Ad
|
|
20 |
*/
|
21 |
public function render(Varien_Object $row)
|
22 |
{
|
|
|
|
|
23 |
$rowContent = $row->getData( $this->getColumn()->getIndex() );
|
24 |
-
|
|
|
|
|
25 |
}
|
26 |
}
|
20 |
*/
|
21 |
public function render(Varien_Object $row)
|
22 |
{
|
23 |
+
$content = '';
|
24 |
+
|
25 |
$rowContent = $row->getData( $this->getColumn()->getIndex() );
|
26 |
+
$content = '<code>'.$rowContent.'</code>';
|
27 |
+
|
28 |
+
return $content;
|
29 |
}
|
30 |
}
|
app/code/local/MageDeveloper/Logging/Block/Adminhtml/Logging/View.php
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Block_Adminhtml_Logging_View extends Mage_Adminhtml_Block_Widget_Form_Container
|
13 |
+
{
|
14 |
+
public function __construct()
|
15 |
+
{
|
16 |
+
$this->_objectId = 'id';
|
17 |
+
$this->_controller = 'adminhtml_logging';
|
18 |
+
$this->_mode = 'view';
|
19 |
+
$this->_blockGroup = 'logging';
|
20 |
+
|
21 |
+
parent::__construct();
|
22 |
+
|
23 |
+
if ($previousUrl = $this->getPreviousUrl()) {
|
24 |
+
$this->_addButton('previous', array(
|
25 |
+
'label' => Mage::helper('logging')->__('Previous'),
|
26 |
+
'onclick' => 'setLocation(\'' . $previousUrl . '\')',
|
27 |
+
), -1);
|
28 |
+
}
|
29 |
+
if ($nextUrl = $this->getNextUrl()) {
|
30 |
+
$this->_addButton('next', array(
|
31 |
+
'label' => Mage::helper('logging')->__('Next'),
|
32 |
+
'onclick' => 'setLocation(\'' . $nextUrl . '\')',
|
33 |
+
), -1);
|
34 |
+
}
|
35 |
+
|
36 |
+
$this->removeButton('reset');
|
37 |
+
$this->removeButton('save');
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Get header text
|
42 |
+
*
|
43 |
+
* @return string
|
44 |
+
*/
|
45 |
+
public function getHeaderText()
|
46 |
+
{
|
47 |
+
return Mage::helper('logging')->__('Show Log Entry');
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Get the id of the previous log entry
|
52 |
+
*
|
53 |
+
* @return int
|
54 |
+
*/
|
55 |
+
public function getPreviousId()
|
56 |
+
{
|
57 |
+
$param = $this->getRequest()->getParam($this->_objectId);
|
58 |
+
$id = Mage::helper('logging/log')->getPreviousLogId($param);
|
59 |
+
return $id;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Get the url to view previous log entry
|
64 |
+
*
|
65 |
+
* @return string
|
66 |
+
*/
|
67 |
+
public function getPreviousUrl()
|
68 |
+
{
|
69 |
+
$id = $this->getPreviousId();
|
70 |
+
if ($id) {
|
71 |
+
return $this->getUrl('*/*/view', array($this->_objectId => $id));
|
72 |
+
}
|
73 |
+
return false;
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Get the id of the next log entry
|
78 |
+
*
|
79 |
+
* @return int
|
80 |
+
*/
|
81 |
+
public function getNextId()
|
82 |
+
{
|
83 |
+
$param = $this->getRequest()->getParam($this->_objectId);
|
84 |
+
$id = Mage::helper('logging/log')->getNextLogId($param);
|
85 |
+
return $id;
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Get the url to view next log entry
|
90 |
+
*
|
91 |
+
* @return string
|
92 |
+
*/
|
93 |
+
public function getNextUrl()
|
94 |
+
{
|
95 |
+
$id = $this->getNextId();
|
96 |
+
if ($id) {
|
97 |
+
return $this->getUrl('*/*/view', array($this->_objectId => $id));
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
}
|
app/code/local/MageDeveloper/Logging/Block/Adminhtml/Logging/View/Form.php
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Block_Adminhtml_Logging_View_Form extends Mage_Adminhtml_Block_Widget_Form
|
13 |
+
{
|
14 |
+
protected function _prepareForm()
|
15 |
+
{
|
16 |
+
$form = new Varien_Data_Form(array(
|
17 |
+
'id' => 'view_form',
|
18 |
+
'action' => $this->getUrl('*/*/view', array()),
|
19 |
+
'method' => 'post',
|
20 |
+
'enctype' => 'multipart/form-data'
|
21 |
+
));
|
22 |
+
|
23 |
+
$form->setHtmlIdPrefix('logging_');
|
24 |
+
$form->setUseContainer(true);
|
25 |
+
|
26 |
+
$this->setForm($form);
|
27 |
+
$fieldset = $form->addFieldset('logging_form_view', array('legend'=>Mage::helper('logging')->__('Log entry')));
|
28 |
+
$fieldset->addType('log_type', 'MageDeveloper_Logging_Lib_Varien_Data_Form_Element_LogType');
|
29 |
+
$fieldset->addType('output', 'MageDeveloper_Logging_Lib_Varien_Data_Form_Element_Output');
|
30 |
+
|
31 |
+
$log = $this->_getLog();
|
32 |
+
|
33 |
+
$fieldset->addField('log_type', 'log_type', array(
|
34 |
+
'label' => Mage::helper('logging')->__('Log Type'),
|
35 |
+
'name' => 'log_type',
|
36 |
+
'value' => $log->getLogType()
|
37 |
+
));
|
38 |
+
|
39 |
+
$fieldset->addField('logtime', 'label', array(
|
40 |
+
'label' => Mage::helper('logging')->__('Timestamp'),
|
41 |
+
'value' => $log->getFormatedTimestamp()
|
42 |
+
));
|
43 |
+
|
44 |
+
if ($log->getClass() != '') {
|
45 |
+
$fieldset->addField('class', 'label', array(
|
46 |
+
'label' => Mage::helper('logging')->__('Class'),
|
47 |
+
'value' => $log->getClass()
|
48 |
+
));
|
49 |
+
}
|
50 |
+
|
51 |
+
if ($log->getMethod() != '') {
|
52 |
+
$fieldset->addField('method', 'label', array(
|
53 |
+
'label' => Mage::helper('logging')->__('Method'),
|
54 |
+
'value' => $log->getMethod()
|
55 |
+
));
|
56 |
+
}
|
57 |
+
|
58 |
+
$fieldset->addField('output', 'output', array(
|
59 |
+
'label' => Mage::helper('logging')->__('Data'),
|
60 |
+
'value' => $log->getOutput()
|
61 |
+
));
|
62 |
+
|
63 |
+
|
64 |
+
return parent::_prepareForm();
|
65 |
+
}
|
66 |
+
|
67 |
+
protected function _getLog()
|
68 |
+
{
|
69 |
+
if (!($this->getData('log') instanceof MageDeveloper_Statistics_Model_Rule)) {
|
70 |
+
$this->setData('log', Mage::registry('log'));
|
71 |
+
}
|
72 |
+
return $this->getData('log');
|
73 |
+
}
|
74 |
+
|
75 |
+
protected function _prepareLayout()
|
76 |
+
{
|
77 |
+
parent::_prepareLayout();
|
78 |
+
if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
|
79 |
+
$this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
|
84 |
+
}
|
85 |
+
|
app/code/local/MageDeveloper/Logging/Helper/Data.php
CHANGED
@@ -86,6 +86,50 @@ class MageDeveloper_Logging_Helper_Data extends Mage_Core_Helper_Abstract
|
|
86 |
return MageDeveloper_Logging_Model_Log::LOG_TYPE_ERROR;
|
87 |
}
|
88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
/**
|
90 |
* Get the model for a log entry
|
91 |
*
|
86 |
return MageDeveloper_Logging_Model_Log::LOG_TYPE_ERROR;
|
87 |
}
|
88 |
|
89 |
+
/**
|
90 |
+
* Set OK Type
|
91 |
+
*
|
92 |
+
* @return self
|
93 |
+
*/
|
94 |
+
public function setTypeOk()
|
95 |
+
{
|
96 |
+
$this->setType( $this->getTypeOk() );
|
97 |
+
return $this;
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Set INFO Type
|
102 |
+
*
|
103 |
+
* @return self
|
104 |
+
*/
|
105 |
+
public function setTypeInfo()
|
106 |
+
{
|
107 |
+
$this->setType( $this->getTypeInfo() );
|
108 |
+
return $this;
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Set WARNING Type
|
113 |
+
*
|
114 |
+
* @return self
|
115 |
+
*/
|
116 |
+
public function setTypeWarning()
|
117 |
+
{
|
118 |
+
$this->setType( $this->getTypeWarning() );
|
119 |
+
return $this;
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Set ERROR Type
|
124 |
+
*
|
125 |
+
* @return self
|
126 |
+
*/
|
127 |
+
public function setTypeError()
|
128 |
+
{
|
129 |
+
$this->setType( $this->getTypeError() );
|
130 |
+
return $this;
|
131 |
+
}
|
132 |
+
|
133 |
/**
|
134 |
* Get the model for a log entry
|
135 |
*
|
app/code/local/MageDeveloper/Logging/Helper/Log.php
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Log extends Mage_Core_Helper_Abstract
|
13 |
+
{
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Get the next found log entry id
|
17 |
+
*
|
18 |
+
* @param int $logId
|
19 |
+
* @return int next log id
|
20 |
+
*/
|
21 |
+
public function getNextLogId($logId)
|
22 |
+
{
|
23 |
+
$select = $this->_getConnection()->select()
|
24 |
+
->from( $this->getLogEntityTableName() )
|
25 |
+
->where('entity_id > ?', $logId)
|
26 |
+
->limit(1);
|
27 |
+
|
28 |
+
$result = $this->_getConnection()->fetchRow($select);
|
29 |
+
|
30 |
+
if (array_key_exists('entity_id', $result)) {
|
31 |
+
return (int)$result['entity_id'];
|
32 |
+
}
|
33 |
+
return false;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Get the previous found log entry id
|
38 |
+
*
|
39 |
+
* @param int $logId
|
40 |
+
* @return int previous log id
|
41 |
+
*/
|
42 |
+
public function getPreviousLogId($logId)
|
43 |
+
{
|
44 |
+
$select = $this->_getConnection()->select()
|
45 |
+
->from( $this->getLogEntityTableName() )
|
46 |
+
->where('entity_id < ?', $logId)
|
47 |
+
->order('entity_id DESC')
|
48 |
+
->limit(1);
|
49 |
+
|
50 |
+
$result = $this->_getConnection()->fetchRow($select);
|
51 |
+
|
52 |
+
if (array_key_exists('entity_id', $result)) {
|
53 |
+
return (int)$result['entity_id'];
|
54 |
+
}
|
55 |
+
return false;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Get Log Entity Table Name
|
60 |
+
*/
|
61 |
+
public function getLogEntityTableName()
|
62 |
+
{
|
63 |
+
return $this->_getTableName('log_entity');
|
64 |
+
}
|
65 |
+
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Get Table Name
|
69 |
+
*/
|
70 |
+
private function _getTableName($table)
|
71 |
+
{
|
72 |
+
return $this->_getResource()->getTableName($table);
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Get database resource
|
77 |
+
*/
|
78 |
+
private function _getResource()
|
79 |
+
{
|
80 |
+
return Mage::getSingleton('core/resource');
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Get database read connection
|
85 |
+
*/
|
86 |
+
private function _getConnection()
|
87 |
+
{
|
88 |
+
return $this->_getResource()->getConnection('core_read');
|
89 |
+
}
|
90 |
+
}
|
app/code/local/MageDeveloper/Logging/Helper/Logtype.php
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Logtype extends MageDeveloper_Logging_Helper_Style
|
13 |
+
{
|
14 |
+
public function _construct()
|
15 |
+
{
|
16 |
+
parent::_construct();
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Get the log type string by
|
21 |
+
* a given log type
|
22 |
+
*
|
23 |
+
* @param int $logType Type of the log
|
24 |
+
* @return string Log Type String
|
25 |
+
*/
|
26 |
+
public function getLogTypeString($logType)
|
27 |
+
{
|
28 |
+
switch ($logType) {
|
29 |
+
case MageDeveloper_Logging_Model_Log::LOG_TYPE_OK:
|
30 |
+
return Mage::helper('logging')->__('OK');
|
31 |
+
case MageDeveloper_Logging_Model_Log::LOG_TYPE_INFO:
|
32 |
+
return Mage::helper('logging')->__('INFO');
|
33 |
+
case MageDeveloper_Logging_Model_Log::LOG_TYPE_WARNING:
|
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
|
46 |
+
*
|
47 |
+
* @param int $logType Type of the log
|
48 |
+
* @return string html
|
49 |
+
*/
|
50 |
+
public function getLogTypeStyle($logType)
|
51 |
+
{
|
52 |
+
$string = $this->getLogTypeString($logType);
|
53 |
+
$this->setLogTypeStyles($logType);
|
54 |
+
|
55 |
+
return $this->getStyledContent($string);
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Prepare the log type styles
|
60 |
+
* by a given log type
|
61 |
+
*
|
62 |
+
* @param int $logType Log Type
|
63 |
+
* @return void
|
64 |
+
*/
|
65 |
+
public function setLogTypeStyles($logType)
|
66 |
+
{
|
67 |
+
// General Styles
|
68 |
+
$this->setStyle('font-weight', 'bold');
|
69 |
+
$this->setStyle('margin', '2px');
|
70 |
+
$this->setStyle('padding', '2px');
|
71 |
+
$this->setStyle('text-align', 'center');
|
72 |
+
|
73 |
+
switch ($logType) {
|
74 |
+
|
75 |
+
case MageDeveloper_Logging_Model_Log::LOG_TYPE_OK:
|
76 |
+
$this->setStyle('background-color', '#c1ffcf');
|
77 |
+
$this->setStyle('color', '#197a52');
|
78 |
+
$this->setStyle('border', '1px solid #197a52');
|
79 |
+
break;
|
80 |
+
|
81 |
+
case MageDeveloper_Logging_Model_Log::LOG_TYPE_INFO:
|
82 |
+
$this->setStyle('background-color', '#bdf7ff');
|
83 |
+
$this->setStyle('color', '#1598cf');
|
84 |
+
$this->setStyle('border', '1px solid #1598cf');
|
85 |
+
break;
|
86 |
+
|
87 |
+
case MageDeveloper_Logging_Model_Log::LOG_TYPE_WARNING:
|
88 |
+
$this->setStyle('background-color', '#feffc1');
|
89 |
+
$this->setStyle('color', '#cea915');
|
90 |
+
$this->setStyle('border', '1px solid #cea915');
|
91 |
+
break;
|
92 |
+
|
93 |
+
case MageDeveloper_Logging_Model_Log::LOG_TYPE_ERROR:
|
94 |
+
$this->setStyle('background-color', '#ffc5bd');
|
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:
|
101 |
+
$this->setStyle('background-color', 'transparent');
|
102 |
+
$this->setStyle('color', '#000000');
|
103 |
+
}
|
104 |
+
return;
|
105 |
+
}
|
106 |
+
|
107 |
+
}
|
108 |
+
|
app/code/local/MageDeveloper/Logging/Helper/Style.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Style extends Mage_Core_Helper_Abstract
|
13 |
+
{
|
14 |
+
/**
|
15 |
+
* CSS Styles
|
16 |
+
* @var array
|
17 |
+
*/
|
18 |
+
protected $_styles;
|
19 |
+
|
20 |
+
public function _construct()
|
21 |
+
{
|
22 |
+
parent::_construct();
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Set a css style
|
27 |
+
*
|
28 |
+
* @param string $style CSS Style Name
|
29 |
+
* @param string $vlaue CSS Style Value
|
30 |
+
* @return void
|
31 |
+
*/
|
32 |
+
public function setStyle($style, $value)
|
33 |
+
{
|
34 |
+
$this->_styles[] = $style.':'.$value;
|
35 |
+
return $this;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Get css styles
|
40 |
+
*
|
41 |
+
* @return string
|
42 |
+
*/
|
43 |
+
public function getStyles()
|
44 |
+
{
|
45 |
+
$string = implode(';',$this->_styles);
|
46 |
+
$this->_styles = array();
|
47 |
+
return $string;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Reset all styles
|
52 |
+
*
|
53 |
+
* @return self
|
54 |
+
*/
|
55 |
+
public function resetStyles()
|
56 |
+
{
|
57 |
+
$this->_styles = array();
|
58 |
+
return $this;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Get styled content
|
63 |
+
*
|
64 |
+
* @param string $content Content to set Styles
|
65 |
+
* @return string Styled Content
|
66 |
+
*/
|
67 |
+
public function getStyledContent($content)
|
68 |
+
{
|
69 |
+
$styles = $this->getStyles();
|
70 |
+
|
71 |
+
if (strlen($styles) <= 0) {
|
72 |
+
return $content;
|
73 |
+
}
|
74 |
+
return '<div style="'.$styles.'">'.$content.'</div>';
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
app/code/local/MageDeveloper/Logging/Lib/Varien/Data/Form/Element/LogType.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Lib_Varien_Data_Form_Element_LogType extends Varien_Data_Form_Element_Abstract
|
13 |
+
{
|
14 |
+
public function __construct($attributes=array())
|
15 |
+
{
|
16 |
+
parent::__construct($attributes);
|
17 |
+
$this->setType('label');
|
18 |
+
}
|
19 |
+
|
20 |
+
public function getElementHtml()
|
21 |
+
{
|
22 |
+
$value = $this->getEscapedValue();
|
23 |
+
$html = '';
|
24 |
+
|
25 |
+
$helper = Mage::helper('logging/logtype');
|
26 |
+
|
27 |
+
$logText = $helper->getLogTypeString($value);
|
28 |
+
|
29 |
+
// Set log styles
|
30 |
+
$helper->setLogTypeStyles($value);
|
31 |
+
$helper->setStyle('width','200px');
|
32 |
+
$helper->setStyle('text-align', 'center');
|
33 |
+
$helper->setStyle('font-size', '17px');
|
34 |
+
|
35 |
+
$html .= $helper->getStyledContent($logText);
|
36 |
+
|
37 |
+
$html.= $this->getAfterElementHtml();
|
38 |
+
return $html;
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
app/code/local/MageDeveloper/Logging/Lib/Varien/Data/Form/Element/Output.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Lib_Varien_Data_Form_Element_Output extends Varien_Data_Form_Element_Abstract
|
13 |
+
{
|
14 |
+
public function __construct($attributes=array())
|
15 |
+
{
|
16 |
+
parent::__construct($attributes);
|
17 |
+
$this->setType('label');
|
18 |
+
}
|
19 |
+
|
20 |
+
public function getElementHtml()
|
21 |
+
{
|
22 |
+
$value = $this->getValue();
|
23 |
+
|
24 |
+
$helper = Mage::helper('logging/style');
|
25 |
+
|
26 |
+
$html = '';
|
27 |
+
|
28 |
+
// Set box styles
|
29 |
+
$helper->setStyle('border', '1px solid #c0c0c0')
|
30 |
+
->setStyle('padding', '5px')
|
31 |
+
->setStyle('width','100%')
|
32 |
+
->setStyle('font-family','Courier, Courier New')
|
33 |
+
->setStyle('background-color','#ffffff');
|
34 |
+
|
35 |
+
$value = $helper->getStyledContent($value);
|
36 |
+
$html .= '<pre>'.$value.'</pre>';
|
37 |
+
|
38 |
+
|
39 |
+
$html.= $this->getAfterElementHtml();
|
40 |
+
return $html;
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
app/code/local/MageDeveloper/Logging/Model/Log.php
CHANGED
@@ -46,5 +46,27 @@ class MageDeveloper_Logging_Model_Log extends Mage_Core_Model_Abstract
|
|
46 |
return $errors;
|
47 |
}
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
}
|
46 |
return $errors;
|
47 |
}
|
48 |
|
49 |
+
/**
|
50 |
+
* Get the log type html code
|
51 |
+
*
|
52 |
+
* @return string HTML Code
|
53 |
+
*/
|
54 |
+
public function getLogTypeHtml()
|
55 |
+
{
|
56 |
+
$type = $this->getLogType();
|
57 |
+
$helper = Mage::helper('logging/logtype');
|
58 |
+
return $helper->getLogTypeStyle($type);
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Get a formated timestamp
|
63 |
+
*
|
64 |
+
* @return string
|
65 |
+
*/
|
66 |
+
public function getFormatedTimestamp($format = 'long', $includeDate = true)
|
67 |
+
{
|
68 |
+
return Mage::helper('core')->formatTime($this->getTimestamp(), $format, $includeDate);
|
69 |
+
}
|
70 |
+
|
71 |
|
72 |
}
|
app/code/local/MageDeveloper/Logging/controllers/Adminhtml/LoggingController.php
CHANGED
@@ -11,6 +11,26 @@
|
|
11 |
|
12 |
class MageDeveloper_Logging_Adminhtml_LoggingController extends Mage_Adminhtml_Controller_Action
|
13 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
/**
|
15 |
* indexAction
|
16 |
*/
|
@@ -20,7 +40,73 @@ class MageDeveloper_Logging_Adminhtml_LoggingController extends Mage_Adminhtml_C
|
|
20 |
$this->renderLayout();
|
21 |
}
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
/**
|
26 |
* massDeleteAction
|
11 |
|
12 |
class MageDeveloper_Logging_Adminhtml_LoggingController extends Mage_Adminhtml_Controller_Action
|
13 |
{
|
14 |
+
protected function _initLog()
|
15 |
+
{
|
16 |
+
$id = (int) $this->getRequest()->getParam('id');
|
17 |
+
|
18 |
+
try {
|
19 |
+
|
20 |
+
$logEntry = Mage::getModel('logging/log')->load($id);
|
21 |
+
|
22 |
+
if ($logEntry instanceof MageDeveloper_Logging_Model_Log) {
|
23 |
+
Mage::register('log', $logEntry);
|
24 |
+
Mage::register('current_log', $logEntry);
|
25 |
+
return $logEntry;
|
26 |
+
}
|
27 |
+
|
28 |
+
|
29 |
+
} catch (Exception $e) {
|
30 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
/**
|
35 |
* indexAction
|
36 |
*/
|
40 |
$this->renderLayout();
|
41 |
}
|
42 |
|
43 |
+
/**
|
44 |
+
* viewAction
|
45 |
+
* Display details of an logging entry
|
46 |
+
*/
|
47 |
+
public function viewAction()
|
48 |
+
{
|
49 |
+
$log = $this->_initLog();
|
50 |
+
|
51 |
+
if (!$log->getId()) {
|
52 |
+
$this->_getSession()->addError(Mage::helper('logging')->__('This log no longer exists.'));
|
53 |
+
$this->_redirect('*/*/');
|
54 |
+
return;
|
55 |
+
}
|
56 |
+
|
57 |
+
$this->_title( Mage::helper('logging')->__('Showing log entry') );
|
58 |
+
|
59 |
+
$this->loadLayout();
|
60 |
+
|
61 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(false);
|
62 |
+
$this->renderLayout();
|
63 |
+
}
|
64 |
|
65 |
+
/**
|
66 |
+
* deleteAction
|
67 |
+
*/
|
68 |
+
public function deleteAction()
|
69 |
+
{
|
70 |
+
if ($id = $this->getRequest()->getParam('id')) {
|
71 |
+
try {
|
72 |
+
$model = Mage::getModel('logging/log');
|
73 |
+
$model->setId($id);
|
74 |
+
$model->delete();
|
75 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('log')->__('The log entry has been deleted.'));
|
76 |
+
$this->_redirect('*/*/');
|
77 |
+
return;
|
78 |
+
}
|
79 |
+
catch (Exception $e) {
|
80 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
81 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
82 |
+
return;
|
83 |
+
}
|
84 |
+
}
|
85 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('logging')->__('Unable to find a log entry to delete.'));
|
86 |
+
$this->_redirect('*/*/');
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* compareAction
|
91 |
+
*/
|
92 |
+
public function compareAction()
|
93 |
+
{
|
94 |
+
$ids = $this->getRequest()->getParam('logging');
|
95 |
+
|
96 |
+
if(!is_array($ids)) {
|
97 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
|
98 |
+
} else {
|
99 |
+
$this->_title( Mage::helper('logging')->__('Compare log entries') );
|
100 |
+
|
101 |
+
$this->loadLayout();
|
102 |
+
|
103 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(false);
|
104 |
+
|
105 |
+
Mage::register('log_ids', $ids);
|
106 |
+
|
107 |
+
$this->renderLayout();
|
108 |
+
}
|
109 |
+
}
|
110 |
|
111 |
/**
|
112 |
* massDeleteAction
|
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>
|
@@ -61,7 +61,6 @@
|
|
61 |
</routers>
|
62 |
</frontend>
|
63 |
|
64 |
-
|
65 |
<admin>
|
66 |
<routers>
|
67 |
<adminhtml>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<MageDeveloper_Logging>
|
5 |
+
<version>1.2.0</version>
|
6 |
</MageDeveloper_Logging>
|
7 |
</modules>
|
8 |
<global>
|
61 |
</routers>
|
62 |
</frontend>
|
63 |
|
|
|
64 |
<admin>
|
65 |
<routers>
|
66 |
<adminhtml>
|
app/design/adminhtml/default/default/layout/logging.xml
CHANGED
@@ -2,7 +2,19 @@
|
|
2 |
<layout>
|
3 |
<adminhtml_logging_index>
|
4 |
<reference name="content">
|
5 |
-
<block type="logging/adminhtml_logging" name="logging" />
|
6 |
</reference>
|
7 |
</adminhtml_logging_index>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
</layout>
|
2 |
<layout>
|
3 |
<adminhtml_logging_index>
|
4 |
<reference name="content">
|
5 |
+
<block type="logging/adminhtml_logging" name="logging.grid" />
|
6 |
</reference>
|
7 |
</adminhtml_logging_index>
|
8 |
+
|
9 |
+
<adminhtml_logging_view>
|
10 |
+
<reference name="content">
|
11 |
+
<block type="logging/adminhtml_logging_view" name="logging.view" />
|
12 |
+
</reference>
|
13 |
+
</adminhtml_logging_view>
|
14 |
+
|
15 |
+
<adminhtml_logging_compare>
|
16 |
+
<reference name="content">
|
17 |
+
<block type="logging/adminhtml_logging_compare" name="logging.compare" />
|
18 |
+
</reference>
|
19 |
+
</adminhtml_logging_compare>
|
20 |
</layout>
|
app/design/adminhtml/default/default/template/logging/compare.phtml
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<table cellspacing="0" cellpadding="0" class="massaction data">
|
2 |
+
<tbody>
|
3 |
+
<tr>
|
4 |
+
<td>
|
5 |
+
<strong>
|
6 |
+
<?php echo $this->__('Log Entries') ?>
|
7 |
+
</strong>
|
8 |
+
</td>
|
9 |
+
<td>
|
10 |
+
<div class="right">
|
11 |
+
<div class="entry-edit">
|
12 |
+
</div>
|
13 |
+
</div>
|
14 |
+
</td>
|
15 |
+
</tr>
|
16 |
+
|
17 |
+
</tbody>
|
18 |
+
</table>
|
19 |
+
<?php $logs = $this->getLogEntries(); ?>
|
20 |
+
<?php $size = $logs->getSize(); ?>
|
21 |
+
<?php $percent = floor(90/$size); ?>
|
22 |
+
<table width="100%" cellpadding="0" cellspacing="0" border="0">
|
23 |
+
<tr valign="middle">
|
24 |
+
<td style="background-color:#f2f2f2;text-align: center;width:100px;vertical-align: middle;">
|
25 |
+
<h4><?php echo $this->__('Log Type'); ?></h4>
|
26 |
+
</td>
|
27 |
+
<?php foreach ($logs as $_log): ?>
|
28 |
+
|
29 |
+
<td style="border:1px solid #f2f2f2;text-align: center;" width="<?php echo $percent.'%'; ?>">
|
30 |
+
<?php echo $_log->getLogTypeHtml(); ?>
|
31 |
+
</td>
|
32 |
+
|
33 |
+
<?php endforeach; ?>
|
34 |
+
</tr>
|
35 |
+
<tr valign="middle">
|
36 |
+
<td style="background-color:#f2f2f2;text-align: center;width:100px;vertical-align: middle;">
|
37 |
+
<h4><?php echo $this->__('Timestamp'); ?></h4>
|
38 |
+
</td>
|
39 |
+
<?php foreach ($logs as $_log): ?>
|
40 |
+
|
41 |
+
<td style="border:1px solid #f2f2f2;text-align: center;" width="<?php echo $percent.'%'; ?>">
|
42 |
+
<?php echo $_log->getFormatedTimestamp(); ?>
|
43 |
+
</td>
|
44 |
+
<?php endforeach; ?>
|
45 |
+
</tr>
|
46 |
+
<tr valign="middle">
|
47 |
+
<td style="background-color:#f2f2f2;text-align: center;width:100px;vertical-align: middle;">
|
48 |
+
<h4><?php echo $this->__('Class'); ?></h4>
|
49 |
+
</td>
|
50 |
+
<?php foreach ($logs as $_log): ?>
|
51 |
+
|
52 |
+
<td style="border:1px solid #f2f2f2;text-align: center;" width="<?php echo $percent.'%'; ?>">
|
53 |
+
<?php echo $_log->getClass(); ?>
|
54 |
+
</td>
|
55 |
+
<?php endforeach; ?>
|
56 |
+
</tr>
|
57 |
+
<tr valign="middle">
|
58 |
+
<td style="background-color:#f2f2f2;text-align: center;width:100px;vertical-align: middle;">
|
59 |
+
<h4><?php echo $this->__('Method'); ?></h4>
|
60 |
+
</td>
|
61 |
+
<?php foreach ($logs as $_log): ?>
|
62 |
+
|
63 |
+
<td style="border:1px solid #f2f2f2;text-align: center;" width="<?php echo $percent.'%'; ?>">
|
64 |
+
<?php echo $_log->getMethod(); ?>
|
65 |
+
</td>
|
66 |
+
<?php endforeach; ?>
|
67 |
+
</tr>
|
68 |
+
<tr valign="middle">
|
69 |
+
<td style="background-color:#f2f2f2;text-align: center;width:100px;vertical-align: middle;">
|
70 |
+
<h4><?php echo $this->__('Data'); ?></h4>
|
71 |
+
</td>
|
72 |
+
<?php foreach ($logs as $_log): ?>
|
73 |
+
|
74 |
+
<td style="border:1px solid #f2f2f2;text-align: center;" width="<?php echo $percent.'%'; ?>">
|
75 |
+
<code><?php echo $_log->getOutput(); ?></code>
|
76 |
+
</td>
|
77 |
+
<?php endforeach; ?>
|
78 |
+
</tr>
|
79 |
+
</table>
|
80 |
+
|
81 |
+
|
82 |
+
|
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>
|
@@ -19,22 +19,19 @@ Mage::helper('logging')
|
|
19 |
->setMessage('My message')
|
20 |
->log();
|
21 |

|
22 |
-
// Log Type
|
23 |
-
$type = Mage::helper('logging')->getTypeOk();
|
24 |
-

|
25 |
Mage::helper('logging')
|
26 |
-
->
|
27 |
->setMessage('Different type')
|
28 |
->log();
|
29 |

|
30 |
-

|
31 |

|
32 |
</description>
|
33 |
-
<notes>
|
34 |
<authors><author><name>Bastian Zagar</name><user>aggy</user><email>zagar@aixdesign.net</email></author></authors>
|
35 |
-
<date>2013-
|
36 |
-
<time>12:
|
37 |
-
<contents><target name="magelocal"><dir name="MageDeveloper"><dir name="Logging"><dir name="Block"><dir name="Adminhtml"><dir name="Logging"><file name="Grid.php" hash="
|
38 |
<compatible/>
|
39 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
40 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>LoggingHelper</name>
|
4 |
+
<version>1.2.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.gnu.org/licenses/gpl-3.0.html">GPL</license>
|
7 |
<channel>community</channel>
|
19 |
->setMessage('My message')
|
20 |
->log();
|
21 |

|
|
|
|
|
|
|
22 |
Mage::helper('logging')
|
23 |
+
->setTypeOk()
|
24 |
->setMessage('Different type')
|
25 |
->log();
|
26 |

|
27 |
+
Types: NOT_SET,OK, INFO, WARNING, ERROR
|
28 |

|
29 |
</description>
|
30 |
+
<notes>New featues: Detail View, Compare</notes>
|
31 |
<authors><author><name>Bastian Zagar</name><user>aggy</user><email>zagar@aixdesign.net</email></author></authors>
|
32 |
+
<date>2013-03-18</date>
|
33 |
+
<time>12:23:14</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="8231770066fe431de3292d971feafa8c"/><dir name="Renderer"><file name="LogType.php" hash="6346c5cf00ef69127531ffde685bd663"/><file name="Pre.php" hash="e3a291fb6a0dab8d6c66ebc83dadd332"/></dir><dir name="View"><file name="Form.php" hash="320435419faa440d43715745d36ea24a"/></dir><file name="View.php" hash="ec7f4561ffe5ee07b2d633faaa4b12ec"/></dir><file name="Logging.php" hash="da1498c795ad6b81c0cb7bd81314a794"/></dir></dir><dir name="Helper"><file name="Data.php" hash="a678e7d6d784af0989fb160f07c7a76f"/><file name="Log.php" hash="e6d1d4a88d4d54b78e69bccff7bd8385"/><file name="Logtype.php" hash="3a7108e21eaa8209774ff2ce5f71d227"/><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="f4bdb6933a92f73b614fc0278344bdd2"/><dir name="Mysql4"><dir name="Log"><file name="Collection.php" hash="1c107fe4e191e07b72196b7b66dc63b1"/></dir><file name="Log.php" hash="9160734fd0857439968e2236963bcca7"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="LoggingController.php" hash="fe3f783f6db31f130470486733680791"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="b861cc7eedd55f1971357a8fe3985a42"/><file name="config.xml" hash="6b616ae1de4bf60b15ff11a5e89ca621"/></dir><dir name="sql"><dir name="magedeveloper_logging_setup"><file name="mysql4-install-1.0.0.php" hash="1fcda8eb4bc11cf3b126db7cba778f42"/></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>
|