Initial commit of the Logs Controller and View.

The log functionality is similar to that of the classic skin, though
with fewer options.  Initial filtering support is for only component type.
Also displays a fixed last 100 log events, sorted by TimeKey ascending.
This commit is contained in:
Kyle Johnson 2013-07-11 12:06:12 -04:00
parent 2ea43105ec
commit 67ad15fdc5
4 changed files with 78 additions and 1 deletions

View File

@ -0,0 +1,30 @@
<?php
class LogsController extends AppController {
public function index() {
$conditions = array();
$named = $this->extractNamedParams(
array('Component')
);
if ($named) {
foreach ($named as $key => $value) {
switch ($key) {
case "Component":
$Component = array($key => $value);
array_push($conditions, $Component);
break;
}
}
};
$this->set('loglines', $this->Log->find('all', array(
'limit' => 100,
'order' => array('TimeKey' => 'asc'),
'conditions' => $conditions
)));
$this->set('components', $this->Log->find('all', array(
'fields' => array('DISTINCT Component')
)));
}
}
?>

View File

@ -50,6 +50,7 @@ $cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework
<li><?php echo $this->Html->link('Dashboard', array('controller' => 'Monitors', 'action' => 'index')); ?></li>
<li><?php echo $this->Html->link('Events', '/Events/'); ?></li>
<li><?php echo $this->Html->link('Options', array('controller' => 'Config', 'action' => 'index')); ?></li>
<li><?php echo $this->Html->link('Logs', array('controller' => 'Logs', 'action' => 'index')); ?></li>
</ol>
</div>
</div>

View File

@ -0,0 +1,35 @@
<?php
$componentoptions = array();
foreach ($components as $component) {
$componentoptions[$component['Log']['Component']] = $component['Log']['Component'];
}
?>
<div>
<?php echo $this->Form->label('Component'); ?>
<?php echo $this->Form->select('Component', $componentoptions); ?>
<?php echo $this->Form->button('Refresh', array('id' => 'btnComponentRefresh')); ?>
</div>
<table id="tblComponents">
<tr>
<th>Date / Time</th>
<th>Component</th>
<th>PID</th>
<th>Level</th>
<th>Message</th>
<th>File</th>
<th>Line</th>
</tr>
<?php
foreach ($loglines as $logline) {
echo "<tr>";
echo '<td>' . date('r', $logline['Log']['TimeKey']) . '</td>';
printf("<td>%s</td>", $logline['Log']['Component']);
printf("<td>%d</td>", $logline['Log']['Pid']);
printf("<td>%d</td>", $logline['Log']['Level']);
printf("<td>%s</td>", $logline['Log']['Message']);
printf("<td>%s</td>", $logline['Log']['File']);
printf("<td>%d</td>", $logline['Log']['Line']);
echo "</tr>";
}
?>
</table>

View File

@ -305,8 +305,13 @@ form div.submit {
margin-top: 10px;
}
label {
text-align:left;
display:inline-block;
margin-top:auto;
margin-bottom:auto;
font-size: 110%;
margin-bottom:3px;
margin-right:5px;
}
input, textarea {
clear: both;
@ -775,3 +780,9 @@ div#footer a{
background-color:#E6E6E6;
}
/* End Config Page */
/* Logs View */
#btnComponentRefresh{
float:right;
}
/* End Logs View */