Handle and display multiline log messages correctly

This commit is contained in:
Alexander A. Klimov 2015-04-24 16:30:29 +02:00
parent ec82b3bc09
commit 7c0be30def
3 changed files with 5 additions and 7 deletions

View File

@ -44,14 +44,12 @@ class ListController extends Controller
}
$this->addTitleTab('application log');
$pattern = '/^(?<datetime>[0-9]{4}(-[0-9]{2}){2}' // date
. 'T[0-9]{2}(:[0-9]{2}){2}([\\+\\-][0-9]{2}:[0-9]{2})?)' // time
. ' - (?<loglevel>[A-Za-z]+)' // loglevel
. ' - (?<message>.*)$/';
$resource = new FileReader(new ConfigObject(array(
'filename' => Config::app()->get('logging', 'file'),
'fields' => $pattern
'fields' => '/(?<!.)(?<datetime>[0-9]{4}(?:-[0-9]{2}){2}' // date
. 'T[0-9]{2}(?::[0-9]{2}){2}(?:[\+\-][0-9]{2}:[0-9]{2})?)' // time
. ' - (?<loglevel>[A-Za-z]+) - (?<message>.*)(?!.)/msS' // loglevel, message
)));
$this->view->logData = $resource->select()->order('DESC')->paginate();

View File

@ -19,7 +19,7 @@
<?= $this->escape($value->loglevel) ?>
</td>
<td>
<?= $this->escape($value->message) ?>
<?= nl2br($this->escape($value->message), false) ?>
</td>
</tr>
<?php endforeach; ?>

View File

@ -58,7 +58,7 @@ class FileReader implements Selectable, Countable
*/
public function iterate()
{
return new FileIterator($this->filename, $this->fields);
return new LogFileIterator($this->filename, $this->fields);
}
/**