function ultimate_cron_function_log_page in Ultimate Cron 8
Same name and namespace in other branches
- 6 ultimate_cron.admin.inc \ultimate_cron_function_log_page()
- 7 ultimate_cron.admin.inc \ultimate_cron_function_log_page()
Function log page.
1 string reference to 'ultimate_cron_function_log_page'
- ultimate_cron_menu in ./
ultimate_cron.module - Implements hook_menu().
File
- ./
ultimate_cron.admin.inc, line 498
Code
function ultimate_cron_function_log_page($function) {
$hooks = ultimate_cron_get_hooks();
if (!isset($hooks[(string) $function])) {
drupal_not_found();
exit;
}
drupal_add_css(drupal_get_path('module', 'ultimate_cron') . '/css/ultimate_cron.admin.css');
$header = array(
array(
'data' => t('Start'),
'field' => 'start_stamp',
'sort' => 'DESC',
),
array(
'data' => t('End'),
'field' => 'end_stamp',
),
t('Duration'),
t('Service host'),
t('Status'),
t('Message'),
);
drupal_set_title(check_plain($function));
$query = db_select('ultimate_cron_log', 'l');
$query = $query
->condition('l.name', $function)
->extend('Drupal\\Core\\Database\\Query\\PagerSelectExtender')
->limit(10)
->extend('Drupal\\Core\\Database\\Query\\TableSortExtender')
->orderByHeader($header)
->fields('l', array(
'lid',
'name',
'start_stamp',
'end_stamp',
'service_host',
'exec_status',
'msg',
'severity',
))
->orderBy('l.start_stamp', 'DESC');
$logs = $query
->execute()
->fetchAll();
$handle_prefix = variable_get('ultimate_cron_handle_prefix', ULTIMATE_CRON_HANDLE_PREFIX);
$output = '';
$rows = array();
if (empty($_GET['page']) && ($process = background_process_get_process($handle_prefix . $function))) {
$data = array(
array(
'class' => array(
'ultimate-cron-admin-start',
),
),
array(
'class' => array(
'ultimate-cron-admin-end',
),
),
array(
'class' => array(
'ultimate-cron-admin-duration',
),
),
array(
'class' => array(
'ultimate-cron-admin-service-host',
),
),
array(
'class' => array(
'ultimate-cron-admin-status ultimate-cron-admin-status-running',
),
),
array(
'class' => array(
'ultimate-cron-admin-message',
),
),
);
$duration = time() - $process->start_stamp;
$duration = gmdate('H:i:s', (int) $duration);
$progress = progress_get_progress($handle_prefix . $function);
if ($progress && $progress->progress > 0) {
$duration .= sprintf(" (%d%%)", $progress->progress * 100);
}
$data[0]['data'] = format_date((int) $process->start_stamp, 'custom', 'Y-m-d H:i:s');
$data[1]['data'] = t('N/A');
$data[2]['data'] = $duration;
$data[3]['data'] = $process->service_host ? $process->service_host : t('N/A');
$data[4]['data'] = '<span>' . t('running') . '</span>';
$data[5]['data'] = '';
$rows[] = $data;
}
foreach ($logs as $log) {
$log->function = $log->name;
$log->status = $log->exec_status;
$log->start = $log->start_stamp;
$log->end = $log->end_stamp;
$severity_type = $log->severity < 0 ? 'success' : ($log->severity >= WATCHDOG_NOTICE ? 'info' : ($log->severity >= WATCHDOG_WARNING ? 'warning' : 'error'));
$css_status = $severity_type;
$data = array(
array(
'class' => array(
'ultimate-cron-admin-start',
),
),
array(
'class' => array(
'ultimate-cron-admin-end',
),
),
array(
'class' => array(
'ultimate-cron-admin-duration',
),
),
array(
'class' => array(
'ultimate-cron-admin-service-host',
),
),
array(
'class' => array(
'ultimate-cron-admin-status ultimate-cron-admin-status-' . $css_status,
),
),
array(
'class' => array(
'ultimate-cron-admin-message',
),
),
);
$data[0]['data'] = format_date((int) $log->start, 'custom', 'Y-m-d H:i:s');
$data[1]['data'] = format_date((int) $log->end, 'custom', 'Y-m-d H:i:s');
$data[2]['data'] = gmdate('H:i:s', (int) ($log->end - $log->start));
$data[3]['data'] = $log->service_host ? $log->service_host : t('N/A');
$data[4]['data'] = '<span>' . $log->status . '</span>';
$data[5]['data'] = $log->msg;
$rows[] = $data;
}
$output .= theme('table', array(
'header' => $header,
'rows' => $rows,
'attributes' => array(
'id' => 'ultimate-cron-view',
),
));
$output .= theme('pager');
return $output;
}