dblog_top
- Versions
- 6 – 7
dblog_top($type)
Menu callback; generic function to display a page of the most frequent dblog events of a specified type.
Code
modules/dblog/dblog.admin.inc, line 95
<?php
function dblog_top($type) {
$header = array(
array('data' => t('Count'), 'field' => 'count', 'sort' => 'desc'),
array('data' => t('Message'), 'field' => 'message')
);
$count_query = db_select('watchdog');
$count_query->addExpression('COUNT(DISTINCT(message))');
$count_query->condition('type', $type);
$query = db_select('watchdog', 'w')->extend('PagerDefault')->extend('TableSort');
$query->addExpression('COUNT(wid)', 'count');
$query = $query
->fields('w', array('message', 'variables'))
->condition('w.type', $type)
->groupBy('message')
->groupBy('variables')
->limit(30)
->orderByHeader($header);
$query->setCountQuery($count_query);
$result = $query->execute();
$rows = array();
foreach ($result as $dblog) {
$rows[] = array($dblog->count, truncate_utf8(_dblog_format_message($dblog), 56, TRUE, TRUE));
}
if (empty($rows)) {
$rows[] = array(array('data' => t('No log messages available.'), 'colspan' => 2));
}
$build['dblog_top_table'] = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
);
$build['dblog_top_pager'] = array('#theme' => 'pager');
return $build;
}
?>Login or register to post comments 