summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2006-08-29 09:51:50 +0000
committerDries Buytaert <dries@buytaert.net>2006-08-29 09:51:50 +0000
commit78ee75f1a2ecc6a788dcf697d36783798ecbbe12 (patch)
tree0face854d3914ddbbba8c8d93a41be9304c1975e
parentbceaf8f0daf1d76bb33afdef8ea231fbc855a5c2 (diff)
downloadbrdo-78ee75f1a2ecc6a788dcf697d36783798ecbbe12.tar.gz
brdo-78ee75f1a2ecc6a788dcf697d36783798ecbbe12.tar.bz2
- Patch #79622 by Dries: added views to see the most popular search terms,
the most important 404s and 403s. This makes the watchdog data easier to use. Improved consistency of the 'amdminister > logs' section.
-rw-r--r--includes/common.inc7
-rw-r--r--modules/search/search.module6
-rw-r--r--modules/statistics/statistics.module11
-rw-r--r--modules/watchdog/watchdog.module43
4 files changed, 53 insertions, 14 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 5a7cb835f..4ab0e2e57 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -318,7 +318,8 @@ function drupal_site_offline() {
*/
function drupal_not_found() {
drupal_set_header('HTTP/1.0 404 Not Found');
- watchdog('page not found', t('%page not found.', array('%page' => $_GET['q'])), WATCHDOG_WARNING);
+
+ watchdog('page not found', check_plain($_GET['q']), WATCHDOG_WARNING);
// Keep old path for reference
if (!isset($_REQUEST['destination'])) {
@@ -347,9 +348,9 @@ function drupal_not_found() {
*/
function drupal_access_denied() {
drupal_set_header('HTTP/1.0 403 Forbidden');
- watchdog('access denied', t('%page denied access.', array('%page' => $_GET['q'])), WATCHDOG_WARNING, l(t('view'), $_GET['q']));
+ watchdog('access denied', check_plain($_GET['q']), WATCHDOG_WARNING);
- // Keep old path for reference
+// Keep old path for reference
if (!isset($_REQUEST['destination'])) {
$_REQUEST['destination'] = $_GET['q'];
}
diff --git a/modules/search/search.module b/modules/search/search.module
index 7e19593b0..074572c89 100644
--- a/modules/search/search.module
+++ b/modules/search/search.module
@@ -170,6 +170,10 @@ function search_menu($may_cache) {
'callback arguments' => array('search_wipe_confirm'),
'access' => user_access('administer search'),
'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/logs/search', 'title' => t('top search phrases'),
+ 'description' => t('View most popular search phrases.'),
+ 'callback' => 'watchdog_top',
+ 'callback arguments' => array('search'));
}
else if (arg(0) == 'search') {
// To remember the user's search keywords when switching across tabs,
@@ -920,7 +924,7 @@ function search_view() {
// Only perform search if there is non-whitespace search term:
if (trim($keys)) {
// Log the search keys:
- watchdog('search', t('Search: %keys (@type).', array('%keys' => $keys, '@type' => module_invoke($type, 'search', 'name'))), WATCHDOG_NOTICE, l(t('results'), 'search/'. $type .'/'. $keys));
+ watchdog('search', t('%keys (@type).', array('%keys' => $keys, '@type' => module_invoke($type, 'search', 'name'))), WATCHDOG_NOTICE, l(t('results'), 'search/'. $type .'/'. $keys));
// Collect the search results:
$results = search_data($keys, $type);
diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module
index 1d468c413..a8dcbb958 100644
--- a/modules/statistics/statistics.module
+++ b/modules/statistics/statistics.module
@@ -117,10 +117,9 @@ function statistics_menu($may_cache) {
$items[] = array(
'path' => 'admin/logs/hits',
'title' => t('recent hits'),
- 'description' => t('View pages that have recently been hit.'),
+ 'description' => t('View pages that have recently been visited.'),
'callback' => 'statistics_recent_hits',
- 'access' => $access,
- 'weight' => 3);
+ 'access' => $access);
$items[] = array(
'path' => 'admin/logs/pages',
'title' => t('top pages'),
@@ -137,7 +136,7 @@ function statistics_menu($may_cache) {
'weight' => 2);
$items[] = array(
'path' => 'admin/logs/referrers',
- 'title' => t('referrers'),
+ 'title' => t('top referrers'),
'description' => t('View top referrers.'),
'callback' => 'statistics_top_referrers',
'access' => $access);
@@ -155,8 +154,8 @@ function statistics_menu($may_cache) {
'callback' => 'drupal_get_form',
'callback arguments' => array('statistics_access_logging_settings'),
'access' => user_access('administer site configuration'),
- 'type' => MENU_NORMAL_ITEM
- );
+ 'type' => MENU_NORMAL_ITEM,
+ 'weight' => 3);
}
else {
if (arg(0) == 'user' && is_numeric(arg(1)) && variable_get('statistics_enable_access_log', 0)) {
diff --git a/modules/watchdog/watchdog.module b/modules/watchdog/watchdog.module
index d941e774f..719122021 100644
--- a/modules/watchdog/watchdog.module
+++ b/modules/watchdog/watchdog.module
@@ -47,10 +47,18 @@ function watchdog_menu($may_cache) {
'callback' => 'system_admin_menu_block_page',
'weight' => 5,
'position' => 'left');
- $items[] = array('path' => 'admin/logs/watchdog', 'title' => t('watchdog log'),
- 'description' => t('View the primary system log.'),
- 'weight' => -10,
- 'callback' => 'watchdog_overview');
+ $items[] = array('path' => 'admin/logs/watchdog', 'title' => t('recent log entries'),
+ 'description' => t('View events that have recently been logged.'),
+ 'callback' => 'watchdog_overview',
+ 'weight' => -1);
+ $items[] = array('path' => 'admin/logs/page-not-found', 'title' => t("top 'page not found' errors"),
+ 'description' => t("View 'page not found errors' (404s)."),
+ 'callback' => 'watchdog_top',
+ 'callback arguments' => array('page not found'));
+ $items[] = array('path' => 'admin/logs/access-denied', 'title' => t("top 'access denied' errors"),
+ 'description' => t("View 'access denied' errors (403s)."),
+ 'callback' => 'watchdog_top',
+ 'callback arguments' => array('access denied'));
$items[] = array('path' => 'admin/logs/event', 'title' => t('details'),
'callback' => 'watchdog_event',
'type' => MENU_CALLBACK);
@@ -160,6 +168,33 @@ function watchdog_overview() {
return $output;
}
+/**
+ * Menu callback; generic function to display a page of the most frequent
+ * watchdog events of a specified type.
+ */
+function watchdog_top($type) {
+
+ $header = array(
+ array('data' => t('Count'), 'field' => 'count', 'sort' => 'desc'),
+ array('data' => t('Message'), 'field' => 'message')
+ );
+
+ $result = pager_query("SELECT COUNT(wid) AS count, message FROM {watchdog} WHERE type = '%s' GROUP BY message ". tablesort_sql($header), 30, 0, "SELECT COUNT(DISTINCT(message)) FROM {watchdog} WHERE type = '%s'", $type);
+
+ while ($watchdog = db_fetch_object($result)) {
+ $rows[] = array($watchdog->count, truncate_utf8($watchdog->message, 56, TRUE, TRUE));
+ }
+
+ if (!$rows) {
+ $rows[] = array(array('data' => t('No log messages available.'), 'colspan' => 2));
+ }
+
+ $output = theme('table', $header, $rows);
+ $output .= theme('pager', NULL, 30, 0);
+
+ return $output;
+}
+
function theme_watchdog_form_overview($form) {
return '<div class="container-inline">'. drupal_render($form) .'</div>';
}