Commit b63747fd authored by Dries's avatar Dries

- Removed the hard-coded list of watchdog types.  The list is compiled
  dynamically and can be extended through the watchdog() call.  (Chris
  could use it to move the cron message to their own category.)
parent f6082cda
......@@ -18,5 +18,5 @@
module_invoke_all("cron");
watchdog("message", "cron run completed");
watchdog("regular", "cron run completed");
?>
......@@ -80,7 +80,7 @@ function drupal_directory_ping($arguments) {
db_query("DELETE FROM {directory} WHERE link = '%s' OR mail = '%s'", $link, $mail);
db_query("INSERT INTO {directory} (link, name, mail, slogan, mission, timestamp) VALUES ('%s', '%s', '%s', '%s', '%s', %d)", $link, $name, $mail, $slogan, $mission, time());
watchdog("message", "directory: ping from '$name' ($link)");
watchdog("regular", "directory: ping from '$name' ($link)");
return new xmlrpcresp(new xmlrpcval(1, "int"));
}
......
......@@ -80,7 +80,7 @@ function drupal_directory_ping($arguments) {
db_query("DELETE FROM {directory} WHERE link = '%s' OR mail = '%s'", $link, $mail);
db_query("INSERT INTO {directory} (link, name, mail, slogan, mission, timestamp) VALUES ('%s', '%s', '%s', '%s', '%s', %d)", $link, $name, $mail, $slogan, $mission, time());
watchdog("message", "directory: ping from '$name' ($link)");
watchdog("regular", "directory: ping from '$name' ($link)");
return new xmlrpcresp(new xmlrpcval(1, "int"));
}
......
......@@ -207,7 +207,7 @@ function _throttle_update($hits) {
variable_set("throttle_cron_timestamp", time());
/* log the change */
if ($throttle_new < $throttle) {
watchdog("message", "message: '". $hits ."' hits in past minute; throttle decreased to level ". $throttle_new);
watchdog("regular", "message: '". $hits ."' hits in past minute; throttle decreased to level ". $throttle_new);
}
else {
watchdog("warning", "warning: '". $hits ."' hits in past minute; throttle increased to level ". $throttle_new);
......
......@@ -207,7 +207,7 @@ function _throttle_update($hits) {
variable_set("throttle_cron_timestamp", time());
/* log the change */
if ($throttle_new < $throttle) {
watchdog("message", "message: '". $hits ."' hits in past minute; throttle decreased to level ". $throttle_new);
watchdog("regular", "message: '". $hits ."' hits in past minute; throttle decreased to level ". $throttle_new);
}
else {
watchdog("warning", "warning: '". $hits ."' hits in past minute; throttle increased to level ". $throttle_new);
......
......@@ -25,6 +25,9 @@ function watchdog_help($section = "admin/help#watchdog") {
case 'admin/watchdog/special':
$output = t("Watchdog events about adding, changing, and moderating nodes and comments.");
break;
case 'admin/watchdog/search':
$output = t("Watchdog events showing what users searched for.");
break;
case 'admin/watchdog/error':
$output = t("Watchdog events about PHP and database errors.");
break;
......@@ -50,13 +53,11 @@ function watchdog_link($type) {
if ($type == "system") {
if (user_access("administer watchdog")) {
menu("admin/watchdog", t("messages"), "watchdog_admin", 6);
menu("admin/watchdog/user", t("user"), "watchdog_admin");
menu("admin/watchdog/regular", t("regular"), "watchdog_admin");
menu("admin/watchdog/special", t("special"), "watchdog_admin");
menu("admin/watchdog/warning", t("warning"), "watchdog_admin");
menu("admin/watchdog/error", t("error"), "watchdog_admin");
menu("admin/watchdog/httpd", t("httpd"), "watchdog_admin");
menu("admin/watchdog/view", t("view details"), "watchdog_admin", 0, MENU_HIDE);
foreach (_watchdog_get_message_types() as $type) {
menu("admin/watchdog/$type", t($type), "watchdog_admin");
}
}
}
}
......@@ -72,7 +73,10 @@ function watchdog_cron() {
}
function watchdog_overview($type) {
$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 != ''");
foreach (_watchdog_get_message_types() as $key) {
$query[$key] = "WHERE type = '". check_query($key) ."'";
}
$query['actions'] = "WHERE link != ''";
$header = array(
array("data" => t("date"), "field" => "w.timestamp", "sort" => "desc"),
......@@ -143,4 +147,15 @@ function watchdog_admin() {
}
}
function _watchdog_get_message_types() {
$types = array();
$result = db_query("SELECT DISTINCT(type) FROM {watchdog}");
while ($object = db_fetch_object($result)) {
$types[] = $object->type;
}
return $types;
}
?>
......@@ -25,6 +25,9 @@ function watchdog_help($section = "admin/help#watchdog") {
case 'admin/watchdog/special':
$output = t("Watchdog events about adding, changing, and moderating nodes and comments.");
break;
case 'admin/watchdog/search':
$output = t("Watchdog events showing what users searched for.");
break;
case 'admin/watchdog/error':
$output = t("Watchdog events about PHP and database errors.");
break;
......@@ -50,13 +53,11 @@ function watchdog_link($type) {
if ($type == "system") {
if (user_access("administer watchdog")) {
menu("admin/watchdog", t("messages"), "watchdog_admin", 6);
menu("admin/watchdog/user", t("user"), "watchdog_admin");
menu("admin/watchdog/regular", t("regular"), "watchdog_admin");
menu("admin/watchdog/special", t("special"), "watchdog_admin");
menu("admin/watchdog/warning", t("warning"), "watchdog_admin");
menu("admin/watchdog/error", t("error"), "watchdog_admin");
menu("admin/watchdog/httpd", t("httpd"), "watchdog_admin");
menu("admin/watchdog/view", t("view details"), "watchdog_admin", 0, MENU_HIDE);
foreach (_watchdog_get_message_types() as $type) {
menu("admin/watchdog/$type", t($type), "watchdog_admin");
}
}
}
}
......@@ -72,7 +73,10 @@ function watchdog_cron() {
}
function watchdog_overview($type) {
$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 != ''");
foreach (_watchdog_get_message_types() as $key) {
$query[$key] = "WHERE type = '". check_query($key) ."'";
}
$query['actions'] = "WHERE link != ''";
$header = array(
array("data" => t("date"), "field" => "w.timestamp", "sort" => "desc"),
......@@ -143,4 +147,15 @@ function watchdog_admin() {
}
}
function _watchdog_get_message_types() {
$types = array();
$result = db_query("SELECT DISTINCT(type) FROM {watchdog}");
while ($object = db_fetch_object($result)) {
$types[] = $object->type;
}
return $types;
}
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment