public function JobController::showLogs in Ultimate Cron 8.2
Displays a detailed cron job logs table.
Parameters
\Drupal\ultimate_cron\Entity\CronJob $ultimate_cron_job: The cron job which will be run.
Return value
array A render array as expected by drupal_render().
1 string reference to 'JobController::showLogs'
File
- src/
Controller/ JobController.php, line 52
Class
- JobController
- A controller to interact with CronJob entities.
Namespace
Drupal\ultimate_cron\ControllerCode
public function showLogs(CronJob $ultimate_cron_job) {
$header = array(
$this
->t('Severity'),
$this
->t('Start Time'),
$this
->t('End Time'),
$this
->t('Message'),
$this
->t('Duration'),
);
$build['ultimate_cron_job_logs_table'] = [
'#type' => 'table',
'#header' => $header,
'#empty' => $this
->t('No log information available.'),
];
$log_entries = $ultimate_cron_job
->getLogEntries();
foreach ($log_entries as $log_entry) {
list($status, $title) = $log_entry
->formatSeverity();
$title = $log_entry->message ? $log_entry->message : $title;
$row = [];
$row['severity'] = $status;
$row['severity']['#wrapper_attributes']['title'] = strip_tags($title);
$row['start_time']['#markup'] = $log_entry
->formatStartTime();
$row['end_time']['#markup'] = $log_entry
->formatEndTime();
$row['message']['#markup'] = $log_entry->message ?: $log_entry
->formatInitMessage();
$row['duration']['#markup'] = $log_entry
->formatDuration();
$build['ultimate_cron_job_logs_table'][] = $row;
}
$build['#title'] = $this
->t('Logs for %label', [
'%label' => $ultimate_cron_job
->label(),
]);
return $build;
}