The watchdog module monitors your website, captures system events in a log and records them to be reviewed by an authorized individual at a later time. The watchdog log is simply a list of events recorded during operation and contains 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.

To ease administration, the watchdog will automatically discard old log entries.

format_interval(3600), 10800 => format_interval(10800), 21600 => format_interval(21600), 32400 => format_interval(32400), 43200 => format_interval(43200), 86400 => format_interval(86400), 172800 => format_interval(172800), 259200 => format_interval(259200), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200), 1000000000 => t("Never")); $output .= form_select(t("Discard entries older than"), "watchdog_clear", variable_get("watchdog_clear", 604800), $period, t("The time watchdog entries should be kept. Older entries will be automatically discarded. Requires crontab.")); return $output; } function watchdog_cron() { db_query("DELETE FROM watchdog WHERE ". time() ." - timestamp > ". variable_get("watchdog_clear", 604800)); } function watchdog_overview($type) { $color = array("user" => "#FFEEAA", "message" => "#FFFFFF", "special" => "#A49FFF", "warning" => "#FFAA22", "httpd" => "#99DD99", "error" => "#EE4C4C"); $query = array("user" => "WHERE type = 'user'", "regular" => "WHERE type = 'message'", "special" => "WHERE type = 'special'", "warning" => "WHERE type = 'warning'", "error" => "WHERE type = 'error'", "httpd" => "WHERE type = 'httpd'", "actions" => "WHERE link != ''"); $result = pager_query("SELECT w.*, u.name, u.uid FROM watchdog w LEFT JOIN users u ON w.uid = u.uid ". ($type ? $query[$type] : "") ." ORDER BY w.timestamp DESC", 100); $output .= ""; $output .= " "; while ($watchdog = db_fetch_object($result)) { if ($background = $color[$watchdog->type]) { $output .= " "; } } if ($pager = pager_display(NULL, 100, 0, "admin")) { $output .= " "; } $output .= "
" . t("date") . "" . t("event") . "" . t("user") . "" . t("operations") . "
". format_date($watchdog->timestamp, "small") ."". substr(strip_tags($watchdog->message), 0, 64) ."". format_name($watchdog) ."$watchdog->link". l(t("view details"), "admin/watchdog/view/$watchdog->wid") ."
$pager
"; return $output; } function watchdog_view($id) { $result = db_query("SELECT w.*, u.name, u.uid FROM watchdog w LEFT JOIN users u ON w.uid = u.uid WHERE w.wid = '%d'", $id); if ($watchdog = db_fetch_object($result)) { $output .= ""; $output .= " "; $output .= " "; $output .= " "; $output .= " "; $output .= " "; $output .= " "; $output .= "
". t("Type") ."$watchdog->type
". t("Date") ."". format_date($watchdog->timestamp, "large") ."
". t("User") ."". format_name($watchdog) ."
". t("Location") ."$watchdog->location
". t("Message") ."$watchdog->message
". t("Hostname") ."$watchdog->hostname
"; return $output; } } function watchdog_admin() { if (user_access("administer watchdog")) { switch (arg(2)) { case "help": watchdog_help(); break; case "view": print watchdog_view(check_input(arg(3))); break; default: print watchdog_overview(arg(3)); } } else { print message_access(); } } ?>