function _hosting_task_log_table in Hosting 7.4
Same name and namespace in other branches
- 5 task/hosting_task.module \_hosting_task_log_table()
- 6.2 task/hosting_task.module \_hosting_task_log_table()
- 7.3 task/hosting_task.module \_hosting_task_log_table()
Display table containing the logged information for this task.
2 calls to _hosting_task_log_table()
- hosting_task_log_ajax in task/
hosting_task.module - Read additional task log data, served via AJAX.
- hosting_task_view in task/
hosting_task.module - Implements hook_view().
File
- task/
hosting_task.module, line 1305 - Web server node type is defined here.
Code
function _hosting_task_log_table($node, $last_position = 0) {
$types = variable_get('hosting_task_logs_types_display', hosting_log_types());
$query_args = array(
':vid' => $node->vid,
':lid' => $last_position,
':types' => $types,
);
$result = db_query("SELECT * FROM {hosting_task_log} WHERE vid = :vid AND lid > :lid AND type IN (:types) ORDER BY lid", $query_args);
if ($result) {
$headers = array(
'data' => 'Log message',
'execution_time' => 'Execution time',
'',
);
$rows = array();
$last_lid = $last_position;
$last_timestamp = 0;
$exec_time = '';
$row_count = -1;
foreach ($result as $entry) {
if (strlen($entry->message) > 300) {
$summary = "<span class='hosting-task-summary'>" . filter_xss(substr($entry->message, 0, 75), array()) . "... <a href='javascript:void(0)' class='hosting-summary-expand modalframe-exclude'>(" . t('Expand') . ')</a></span>';
$message = $summary . "<span class='hosting-task-full'>" . filter_xss($entry->message) . '</span>';
}
else {
$message = filter_xss($entry->message);
}
// Add error and warning anchors, so we can provide a quick link to them.
if ($entry->type == 'error') {
$message = '<a name="error"></a>' . $message;
}
elseif ($entry->type == 'warning') {
$message = '<a name="warning"></a>' . $message;
}
// Add the exec_time to the previous row
$exec_time = $entry->timestamp - $last_timestamp;
// "1" is unreliable because timestamps don't allow sub-second granularity.
if ($exec_time < 1) {
$exec_time = '<div>-</div>';
}
elseif ($exec_time == 1) {
$exec_time = '<div title="Many tasks take less than 1 second to perform. This duration represents an aggregate of the preceding tasks\' duration."><strong>' . $exec_time . ' s.</strong></div>';
}
else {
$exec_time = '<div><strong>' . $exec_time . ' s.</strong></div>';
}
if ($row_count > -1) {
$rows[$row_count]['data'][1] = array(
'data' => $exec_time,
);
}
$row_count++;
$last_timestamp = $entry->timestamp;
$row = array(
array(
'data' => $message,
'class' => array(
'hosting-status',
),
),
'',
$entry->type,
);
$rows[] = array(
'data' => $row,
'class' => array(
_hosting_task_log_class($entry->type),
),
);
// Record that we've seen this log row.
$last_lid = $entry->lid;
}
$table = array(
'#theme' => "table",
'#header' => $headers,
'#rows' => $rows,
'#attributes' => array(
'id' => 'hosting-task-log',
'class' => array(
'hosting-table',
),
),
);
// If the task has not finished executing, update via AJAX.
if (!hosting_task_task_has_finished($node)) {
$table += array(
'#refresh_url' => url('hosting/task/log/ajax/' . $node->nid . '/' . $last_lid),
'#attached' => array(
'js' => array(
array(
'data' => array(
'hosting_task' => array(
'refresh_url' => url('hosting/task/log/ajax/' . $node->nid . '/' . $last_lid),
),
),
'type' => 'setting',
),
drupal_get_path('module', 'hosting_task') . '/js/hosting_task.table.js',
),
'library' => array(
array(
'system',
'drupal.ajax',
),
),
),
);
}
return $table;
}
return FALSE;
}