function elasticsearch_watchdog_event in Elasticsearch Connector 7.2
Same name and namespace in other branches
- 7.5 modules/elasticsearch_watchdog/elasticsearch_watchdog.admin.inc \elasticsearch_watchdog_event()
- 7 modules/elasticsearch_watchdog/elasticsearch_watchdog.admin.inc \elasticsearch_watchdog_event()
Page callback: Displays details about a specific log message.
Parameters
int $id: Unique ID of the log message.
Return value
array|string If the ID is located in the Elasticsearch index, a build array in the format expected by drupal_render(); otherwise, an empty string.
See also
1 string reference to 'elasticsearch_watchdog_event'
- elasticsearch_watchdog_menu in modules/
elasticsearch_watchdog/ elasticsearch_watchdog.module - Implements hook_menu().
File
- modules/
elasticsearch_watchdog/ elasticsearch_watchdog.admin.inc, line 432 - Created on Jan 06, 2014
Code
function elasticsearch_watchdog_event($id) {
$severity = watchdog_severity_levels();
$client_id = elasticsearch_watchdog_get_cluster_id();
if (!empty($client_id)) {
$client = elasticsearch_connector_get_client_by_id($client_id);
if ($client) {
$params = array();
$params['index'] = elasticsearch_watchdog_get_index_name();
$params['type'] = elasticsearch_watchdog_get_type_name_for_view();
$params['id'] = $id;
if ($client
->exists($params)) {
$result = $client
->get($params);
if (!empty($result['_id'])) {
$source = $result['_source'];
$account = user_load($source['uid']);
$rows = array(
array(
array(
'data' => t('Type'),
'header' => TRUE,
),
$source['type'],
),
array(
array(
'data' => t('Date'),
'header' => TRUE,
),
format_date($source['timestamp'], 'long'),
),
array(
array(
'data' => t('User'),
'header' => TRUE,
),
theme('username', array(
'account' => $account,
)),
),
array(
array(
'data' => t('Location'),
'header' => TRUE,
),
l($source['location'], $source['location']),
),
array(
array(
'data' => t('Referrer'),
'header' => TRUE,
),
l($source['referer'], $source['referer']),
),
array(
array(
'data' => t('Message'),
'header' => TRUE,
),
theme('elasticsearch_watchdog_message', array(
'event_id' => $id,
'event' => $source,
)),
),
array(
array(
'data' => t('Severity'),
'header' => TRUE,
),
$severity[$source['severity']],
),
array(
array(
'data' => t('Hostname'),
'header' => TRUE,
),
check_plain($source['hostname']),
),
array(
array(
'data' => t('Domain'),
'header' => TRUE,
),
check_plain($source['domain']),
),
array(
array(
'data' => t('Operations'),
'header' => TRUE,
),
$source['link'],
),
);
$build['elasticsearch_watchdog_table'] = array(
'#theme' => 'table',
'#rows' => $rows,
'#attributes' => array(
'class' => array(
'elasticlog-event',
),
),
);
return $build;
}
else {
drupal_set_message(t('The Client ID does not exists in elasticsearch server.'), 'error');
}
}
else {
drupal_set_message(t("The log with ID: %id does not exist.", array(
'%id' => $id,
)), 'error');
}
}
}
else {
drupal_set_message(t('Elasticsearch connector not specified.'), 'error');
}
drupal_goto('admin/reports/elasticlog');
}