Same name and namespace in other branches
- 4.7.x modules/watchdog.module \watchdog_overview()
- 5.x modules/watchdog/watchdog.module \watchdog_overview()
Menu callback; displays a listing of log messages.
1 call to watchdog_overview()
- system_admin_page in modules/
system.module - Menu callback; provides the main page of the administration section.
1 string reference to 'watchdog_overview'
- watchdog_menu in modules/
watchdog.module - Implementation of hook_menu().
File
- modules/
watchdog.module, line 62 - System monitoring and logging for administrators.
Code
function watchdog_overview() {
$icons = array(
WATCHDOG_NOTICE => '',
WATCHDOG_WARNING => theme('image', 'misc/watchdog-warning.png', t('warning'), t('warning')),
WATCHDOG_ERROR => theme('image', 'misc/watchdog-error.png', t('error'), t('error')),
);
$classes = array(
WATCHDOG_NOTICE => 'watchdog-notice',
WATCHDOG_WARNING => 'watchdog-warning',
WATCHDOG_ERROR => 'watchdog-error',
);
$names['all'] = t('all messages');
$queries['all'] = '';
foreach (_watchdog_get_message_types() as $type) {
$names[$type] = t('%type messages', array(
'%type' => t($type),
));
$queries[$type] = "WHERE type = '" . db_escape_string($type) . "'";
}
if (empty($_SESSION['watchdog_overview_filter'])) {
$_SESSION['watchdog_overview_filter'] = 'all';
}
$op = $_POST['op'];
if ($op == t('Filter') && isset($_POST['edit']['filter'])) {
$_SESSION['watchdog_overview_filter'] = $_POST['edit']['filter'];
}
$form = form_select(t('Filter by message type'), 'filter', $_SESSION['watchdog_overview_filter'], $names);
$form .= form_submit(t('Filter'));
$header = array(
' ',
array(
'data' => t('Type'),
'field' => 'w.type',
),
array(
'data' => t('Date'),
'field' => 'w.wid',
'sort' => 'desc',
),
array(
'data' => t('Message'),
'field' => 'w.message',
),
array(
'data' => t('User'),
'field' => 'u.name',
),
array(
'data' => t('Operations'),
'colspan' => '2',
),
);
$sql = 'SELECT w.*, u.name, u.uid FROM {watchdog} w INNER JOIN {users} u ON w.uid = u.uid ' . $queries[$_SESSION['watchdog_overview_filter']] . tablesort_sql($header);
$result = pager_query($sql, 50);
while ($watchdog = db_fetch_object($result)) {
$rows[] = array(
'data' => array(
// Cells
$icons[$watchdog->severity],
t($watchdog->type),
format_date($watchdog->timestamp, 'small'),
truncate_utf8($watchdog->message, 64),
format_name($watchdog),
$watchdog->link,
l(t('details'), "admin/logs/event/{$watchdog->wid}"),
),
// Attributes for tr
'class' => "watchdog-" . preg_replace('/[^a-z]/i', '-', $watchdog->type) . ' ' . $classes[$watchdog->severity],
);
}
if (!$rows) {
$rows[] = array(
array(
'data' => t('No log messages available.'),
'colspan' => '7',
),
);
}
$pager = theme('pager', NULL, 50, 0, tablesort_pager());
if (!empty($pager)) {
$rows[] = array(
array(
'data' => $pager,
'colspan' => '7',
),
);
}
$output = '<div class="container-inline">' . form($form) . '</div>';
$output .= theme('table', $header, $rows);
print theme('page', $output);
}