1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-15 19:24:28 +02:00

Minor improvements to ProcessLogger module

This commit is contained in:
Ryan Cramer
2023-10-19 10:21:08 -04:00
parent 996a1b6854
commit 88ad063af1

View File

@@ -69,8 +69,9 @@ class ProcessLogger extends Process {
} }
public function ___execute() { public function ___execute() {
$log = $this->wire()->log;
/** @var MarkupAdminDataTable $table */ /** @var MarkupAdminDataTable $table */
$table = $this->wire('modules')->get('MarkupAdminDataTable'); $table = $this->wire()->modules->get('MarkupAdminDataTable');
$table->setEncodeEntities(false); $table->setEncodeEntities(false);
$table->headerRow(array( $table->headerRow(array(
$this->_x('Name', 'th'), $this->_x('Name', 'th'),
@@ -78,24 +79,25 @@ class ProcessLogger extends Process {
$this->_x('Entries', 'th'), $this->_x('Entries', 'th'),
$this->_x('Size', 'th'), $this->_x('Size', 'th'),
)); ));
$logs = $this->wire()->log->getLogs(); $logInfos = $log->getLogs(true);
foreach($logs as $log) { foreach($logInfos as $logInfo) {
$logName = $log['name']; $logName = $logInfo['name'];
if(ctype_digit($logName)) $logName = " $logName"; if(ctype_digit($logName)) $logName = " $logName";
$table->row(array( $table->row(array(
$logName => "./view/$log[name]/", $logName => "./view/$logInfo[name]/",
"<span style='font-size: 0;'>$log[modified] </span>" . wireRelativeTimeStr($log['modified']), "<span style='font-size: 0;'>$logInfo[modified] </span>" . wireRelativeTimeStr($logInfo['modified']),
$this->wire()->log->getTotalEntries($log['name']), $log->getTotalEntries($logInfo['name']),
"<span style='font-size: 0;'>$log[size] </span>" . wireBytesStr($log['size']) "<span style='font-size: 0;'>$logInfo[size] </span>" . wireBytesStr($logInfo['size'])
)); ));
} }
$cnt = count($logs); $cnt = count($logInfos);
$icon = wireIconMarkup('tree', 'fw lg');
$out = $out =
"<h2><i class='fa fa-lg fa-fw fa-tree'></i> " . sprintf($this->_n('%d log', '%d logs', $cnt), $cnt) . "</h2>" . "<h2>" . $icon . sprintf($this->_n('%d log', '%d logs', $cnt), $cnt) . "</h2>" .
$table->render() . $table->render() .
"<p>" . "<p>" .
"<span class='detail'>" . $this->_('Create or add to log file from the API:') . "</span><br />" . "<span class='detail'>" . $this->_('Create or add to log file from the API:') . "</span><br />" .
"<code class='notes'>wire('log')->save('name', 'entry text');</code>" . "<code class='notes'>wire()->log->save('name', 'entry text');</code>" .
"</p>"; "</p>";
return $out; return $out;
@@ -382,6 +384,8 @@ class ProcessLogger extends Process {
} else { } else {
$table->headerRow($headers); $table->headerRow($headers);
} }
$leafIcon = wireIconMarkup('leaf', 'ProcessLogNew');
foreach($items as $entry) { foreach($items as $entry) {
@@ -390,7 +394,7 @@ class ProcessLogger extends Process {
if($time && $ts > $time) { if($time && $ts > $time) {
// highlight new items // highlight new items
$date = "<i class='fa fa-leaf ProcessLogNew'></i> $date"; $date = $leafIcon . $date;
} }
if(strpos($entry['text'], '&') !== false) { if(strpos($entry['text'], '&') !== false) {
@@ -450,14 +454,15 @@ class ProcessLogger extends Process {
$pagerOut = ''; $pagerOut = '';
} }
$pageNum = $this->wire('input')->pageNum(); $pageNum = $this->wire()->input->pageNum();
$time = time(); $time = time();
$spinner = wireIconMarkup('tree', "fw lf $iconClass id='ProcessLogPage'");
$out = $out =
"<div id='ProcessLogPage' data-page='$pageNum' data-time='$time'>" . "<div id='ProcessLogPage' data-page='$pageNum' data-time='$time'>" .
$pagerOut . $pagerOut .
"<h2 id='ProcessLogHeadline'>" . "<h2 id='ProcessLogHeadline'>" .
"<i id='ProcessLogSpinner' class='fa fa-fw fa-lg fa-tree $iconClass'></i> $pagerHeadline " . "$spinner $pagerHeadline " .
"<small class='notes'></small></h2>" . "<small class='notes'></small></h2>" .
$table->render() . $table->render() .
"<div class='ui-helper-clearfix'>$pagerOut</div>" . "<div class='ui-helper-clearfix'>$pagerOut</div>" .