summaryrefslogtreecommitdiff
path: root/modules/watchdog
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2004-11-28 12:28:35 +0000
committerDries Buytaert <dries@buytaert.net>2004-11-28 12:28:35 +0000
commit70fcf51e844942d32e81de6c98f5b4d1e9dd1b4e (patch)
treef4d7c393f9bf54f993566c04d90152dcdde6f40b /modules/watchdog
parent76eace311e206c352d9d965a099d5d4cc457249a (diff)
downloadbrdo-70fcf51e844942d32e81de6c98f5b4d1e9dd1b4e.tar.gz
brdo-70fcf51e844942d32e81de6c98f5b4d1e9dd1b4e.tar.bz2
- Refactored the statistics and watchdog module (views). The most important
changes are: 1. Simplified the statistics pages: there are less pages and on the remaining pages there is a lot less visual clutter (less columns and better presentation). 2. Reorganized the 'administer - logs' menu: flattened the menu structure and removed a number of links. 3. Improved performance. Most statistics pages used about 160 slow SQL queries which made the statistics pages fairly unusable on my system. The new pages use at least 10 times less SQL queries and render much faster. They are actually usable. 4. There is now a 'track'-tab on node pages, and a second subtrab on the user accounts 'track'-tab for people with the 'access statistics' permission. They can be used to resp. track the node and the user. This makes the statistics more accessible. 5. Changed the way watchdog messages are filtered. This makes it easier to introduce new watchdog types. 6. Reworked the statistics module's permissions. 7. Less code: 223 insertions(+), 343 deletions(-). 8. Fixed several glitches: for example, the statistics pages sorted the 'Name' column by user ID instead of by name. Unfortunately, it is too difficult to backport these to DRUPAL-4-5. TODO: 1. Review the statistics modules help pages. 2. Help fine-tune the interfaces/views. NOTES: 1. You'll want to run update.php.
Diffstat (limited to 'modules/watchdog')
-rw-r--r--modules/watchdog/watchdog.module60
1 files changed, 31 insertions, 29 deletions
diff --git a/modules/watchdog/watchdog.module b/modules/watchdog/watchdog.module
index 15f2afef7..42b401e90 100644
--- a/modules/watchdog/watchdog.module
+++ b/modules/watchdog/watchdog.module
@@ -21,20 +21,6 @@ function watchdog_help($section = 'admin/help#watchdog') {
return t('<p>The watchdog module monitors your web site, capturing system events in a log to be reviewed by an authorized individual at a later time. The watchdog log is simply a list of recorded events containing usage data, performance data, errors, warnings and operational information. It is vital to <a href="%watchdog">check the watchdog report</a> on a regular basis as it is often the only way to tell what is going on.</p>', array('%watchdog' => url('admin/logs')));
case 'admin/logs':
return t('<p>The watchdog module monitors your web site, capturing system events in a log to be reviewed by an authorized individual at a later time. The watchdog log is simply a list of recorded events containing usage data, performance data, errors, warnings and operational information. It is vital to check the watchdog report on a regular basis as it is often the only way to tell what is going on.</p>');
- case 'admin/logs/error':
- return t('<p>Watchdog events about PHP and database errors.</p>');
- case 'admin/logs/httpd':
- return t('<p>Watchdog events that are from the web server, like 404s, etc.</p>');
- case 'admin/logs/regular':
- return t('<p>Watchdog events that are "normal" and have no other classification.</p>');
- case 'admin/logs/search':
- return t('<p>Watchdog events showing what users have searched for.</p>');
- case 'admin/logs/special':
- return t('<p>Watchdog events about adding, changing, and moderating nodes and comments.</p>');
- case 'admin/logs/user':
- return t('<p>Watchdog events that have to do with users and their accounts.</p>');
- case 'admin/logs/warning':
- return t('<p>Watchdog events that don\'t stop normal operation, but are things you should know.</p>');
case 'admin/modules#description':
return t('Logs and records system events.');
}
@@ -49,14 +35,9 @@ function watchdog_menu($may_cache) {
if ($may_cache) {
$items[] = array('path' => 'admin/logs', 'title' => t('logs'),
'callback' => 'watchdog_overview', 'access' => user_access('administer watchdog'));
-
- $items[] = array('path' => 'admin/logs/view', 'title' => t('view details'),
- 'callback' => 'watchdog_view', 'access' => user_access('administer watchdog'),
+ $items[] = array('path' => 'admin/logs/event', 'title' => t('details'),
+ 'callback' => 'watchdog_event', 'access' => user_access('administer watchdog'),
'type' => MENU_CALLBACK);
-
- foreach (_watchdog_get_message_types() as $type) {
- $items[] = array('path' => 'admin/logs/'. $type, 'title' => t($type), 'type' => MENU_DYNAMIC_ITEM);
- }
}
return $items;
}
@@ -81,29 +62,46 @@ function watchdog_cron() {
/**
* Menu callback; displays a listing of log messages.
*/
-function watchdog_overview($type = '') {
- foreach (_watchdog_get_message_types() as $key) {
- $query[$key] = "WHERE type = '". db_escape_string($key) ."'";
+function watchdog_overview() {
+ $names['all'] = t('all messages');
+ $queries['all'] = '';
+ foreach (_watchdog_get_message_types() as $type) {
+ $names[$type] = t('%type messages', array('%type' => $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 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.timestamp', '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 '. ($type ? $query[$type] : '') . tablesort_sql($header);
+ $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
+ $watchdog->type,
format_date($watchdog->timestamp, 'small'),
truncate_utf8(strip_tags($watchdog->message), 64),
format_name($watchdog),
$watchdog->link,
- l(t('details'), "admin/logs/view/$watchdog->wid")
+ l(t('details'), "admin/logs/event/$watchdog->wid")
),
// Attributes for tr
'class' => "watchdog-$watchdog->type"
@@ -118,13 +116,17 @@ function watchdog_overview($type = '') {
if (!empty($pager)) {
$rows[] = array(array('data' => $pager, 'colspan' => '5'));
}
- print theme('page', theme('table', $header, $rows));
+
+ $output = '<div class="container-inline">'. form($form) .'</div>';
+ $output .= theme('table', $header, $rows);
+
+ print theme('page', $output);
}
/**
* Menu callback; displays details about a log message.
*/
-function watchdog_view($id) {
+function watchdog_event($id) {
$output = '';
$result = db_query('SELECT w.*, u.name, u.uid FROM {watchdog} w INNER JOIN {users} u ON w.uid = u.uid WHERE w.wid = %d', $id);
if ($watchdog = db_fetch_object($result)) {
@@ -132,7 +134,7 @@ function watchdog_view($id) {
$output .= ' <tr><th>'. t('Type') ."</th><td>$watchdog->type</td></tr>";
$output .= ' <tr><th>'. t('Date') .'</th><td>'. format_date($watchdog->timestamp, 'large') .'</td></tr>';
$output .= ' <tr><th>'. t('User') .'</th><td>'. format_name($watchdog) .'</td></tr>';
- $output .= ' <tr><th>'. t('Location') ."</th><td>$watchdog->location</td></tr>";
+ $output .= ' <tr><th>'. t('Location') ."</th><td>". l($watchdog->location, $watchdog->location) ."</td></tr>";
$output .= ' <tr><th>'. t('Message') ."</th><td>$watchdog->message</td></tr>";
$output .= ' <tr><th>'. t('Hostname') ."</th><td>$watchdog->hostname</td></tr>";
$output .= '</table>';