Commit 1045715f authored by Dries's avatar Dries

- Added very basic 'filters' to the watchdog.module which should make it
  easier to sort through all the watchdog "noise".  I'm sure the current
  filters will do for 99% of all the Drupal sites though.

  (Sorry for the awful color scheme, Coney but I can't do any better.)
parent abcef73d
......@@ -27,7 +27,7 @@ function account_create($error = "") {
if ($error) {
$output .= "<P><FONT COLOR=\"red\">". t("Failed to create account") .": ". check_output($error) .".</FONT></P>\n";
watchdog("message", "failed to create account: $error.");
watchdog("account", "failed to create account: $error.");
}
else {
$output .= "<P>". t("Registering allows you to comment, to moderate comments and pending submissions, to customize the look and feel of the site and generally helps you interact with the site more efficiently.") ."</P><P>". t("To create an account, simply fill out this form an click the 'Create account' button below. An e-mail will then be sent to you with instructions on how to validate your account.") ."</P>\n";
......@@ -52,22 +52,22 @@ function account_session_start($userid, $passwd) {
if ($userid && $passwd) $user = new User($userid, $passwd);
if ($user->id) {
if ($rule = user_ban($user->userid, "username")) {
watchdog("message", "failed to login for '$user->userid': banned by $rule->type rule '$rule->mask'");
watchdog("account", "failed to login for '$user->userid': banned by $rule->type rule '$rule->mask'");
}
else if ($rule = user_ban($user->last_host, "hostname")) {
watchdog("message", "failed to login for '$user->userid': banned by $rule->type rule '$rule->mask'");
watchdog("account", "failed to login for '$user->userid': banned by $rule->type rule '$rule->mask'");
}
else {
session_register("user");
watchdog("message", "session opened for '$user->userid'");
watchdog("account", "session opened for '$user->userid'");
}
}
else watchdog("message", "failed to login for '$userid': invalid username - password combination");
else watchdog("account", "failed to login for '$userid': invalid username - password combination");
}
function account_session_close() {
global $user;
watchdog("message", "session closed for user '$user->userid'");
watchdog("account", "session closed for user '$user->userid'");
session_unset();
session_destroy();
unset($user);
......@@ -255,14 +255,14 @@ function account_email_submit($userid, $email) {
$subject = strtr(t("Account details for %a"), array("%a" => variable_get(site_name, "drupal")));
$message = strtr(t("%a,\n\n\nyou requested us to e-mail you a new password for your account at %b. You will need to re-confirm your account or you will not be able to login. To confirm your account updates visit the URL below:\n\n %c\n\nOnce confirmed you can login using the following username and password:\n\n username: %a\n password: %d\n\n\n-- %b team"), array("%a" => $userid, "%b" => variable_get(site_name, "drupal"), "%c" => $link, "%d" => $passwd));
watchdog("message", "new password: `$userid' &lt;$email&gt;");
watchdog("account", "new password: `$userid' &lt;$email&gt;");
mail($email, $subject, $message, "From: noreply");
$output = t("Your password and further instructions have been sent to your e-mail address.");
}
else {
watchdog("warning", "new password: '$userid' and &lt;$email&gt; do not match");
watchdog("account", "new password: '$userid' and &lt;$email&gt; do not match");
$output = t("Could not sent password: no match for the specified username and e-mail address.");
}
......@@ -292,7 +292,7 @@ function account_create_submit($userid, $email) {
$subject = strtr(t("Account details for %a"), array("%a" => variable_get(site_name, "drupal")));
$message = strtr(t("%a,\n\n\nsomeone signed up for a user account on %b and supplied this e-mail address as their contact. If it wasn't you, don't get your panties in a knot and simply ignore this mail. If this was you, you will have to confirm your account first or you will not be able to login. To confirm your account visit the URL below:\n\n %c\n\nOnce confirmed you can login using the following username and password:\n\n username: %a\n password: %d\n\n\n-- %b team\n"), array("%a" => $new[userid], "%b" => variable_get(site_name, "drupal"), "%c" => $link, "%d" => $new[passwd]));
watchdog("message", "new account: `$new[userid]' &lt;$new[real_email]&gt;");
watchdog("account", "new account: `$new[userid]' &lt;$new[real_email]&gt;");
mail($new[real_email], $subject, $message, "From: noreply");
......@@ -312,7 +312,7 @@ function account_create_confirm($name, $hash) {
if ($account->hash == $hash) {
db_query("UPDATE users SET status = '2', hash = '' WHERE userid = '$name'");
$output = t("Your account has been successfully confirmed.");
watchdog("message", "$name: account confirmation successful");
watchdog("account", "$name: account confirmation successful");
}
else {
$output = t("Confirmation failed: invalid confirmation hash.");
......
......@@ -152,7 +152,7 @@ function account_edit_save($name, $edit) {
}
}
watchdog("message", "account: modified user '$name'");
watchdog("account", "account: modified user '$name'");
}
function account_edit($name) {
......
......@@ -17,16 +17,17 @@ function watchdog_cron() {
db_query("DELETE FROM watchdog WHERE ". time() ." - timestamp > ". variable_get("watchdog_clear", 604800));
}
function watchdog_overview() {
$colors = array(message => "#FFFFFF", special => "#836FFF", warning => "#FFAA22", httpd => "#77BB77", error => "#EE2C2C");
function watchdog_overview($type) {
$color = array(account => "#FFEEAA", message => "#FFFFFF", special => "#A49FFF", warning => "#FFAA22", httpd => "#99DD99", error => "#EE4C4C");
$query = array(account => "WHERE type = 'account'", regular => "WHERE type = 'message'", special => "WHERE type = 'special'", warning => "WHERE type = 'warning'", error => "WHERE type = 'error'", httpd => "WHERE type = 'httpd'");
$result = db_query("SELECT w.*, u.userid FROM watchdog w LEFT JOIN users u ON w.user = u.id ORDER BY timestamp DESC LIMIT 1000");
$result = db_query("SELECT w.*, u.userid FROM watchdog w LEFT JOIN users u ON w.user = u.id ". ($type ? $query[$type] : "") ." ORDER BY timestamp DESC LIMIT 1000");
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR><TH>date</TH><TH>message</TH><TH>user</TH><TH>operations</TH></TR>\n";
while ($watchdog = db_fetch_object($result)) {
if ($color = $colors[$watchdog->type]) {
$output .= " <TR BGCOLOR=\"$color\"><TD>". format_date($watchdog->timestamp) ."</TD><TD>". substr(check_output($watchdog->message), 0, 50) ."</TD><TD ALIGN=\"center\">". format_username($watchdog->userid) ."</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=watchdog&op=view&id=$watchdog->id\">details</A></TD></TR>\n";
if ($background = $color[$watchdog->type]) {
$output .= " <TR BGCOLOR=\"$background\"><TD>". format_date($watchdog->timestamp, "small") ."</TD><TD>". substr(check_output($watchdog->message), 0, 50) ."</TD><TD ALIGN=\"center\">". format_username($watchdog->userid) ."</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=watchdog&op=view&id=$watchdog->id\">details</A></TD></TR>\n";
}
}
$output .= "</TABLE>\n";
......@@ -52,9 +53,9 @@ function watchdog_view($id) {
}
function watchdog_admin() {
global $op, $id, $order;
global $op, $id, $type, $order;
print "<SMALL><A HREF=\"admin.php?mod=watchdog\">overview</A> | <A HREF=\"admin.php?mod=watchdog&op=help\">help</A></SMALL><HR>\n";
print "<SMALL><A HREF=\"admin.php?mod=watchdog&type=account\">account messages</A> | <A HREF=\"admin.php?mod=watchdog&type=message\">regular messages</A> | <A HREF=\"admin.php?mod=watchdog&type=special\">special messages</A> | <A HREF=\"admin.php?mod=watchdog&type=warning\">warning messages</A> | <A HREF=\"admin.php?mod=watchdog&type=error\">error messages</A> | <A HREF=\"admin.php?mod=watchdog&type=httpd\">httpd messages</A> | <A HREF=\"admin.php?mod=watchdog\">overview</A> | <A HREF=\"admin.php?mod=watchdog&op=help\">help</A></SMALL><HR>\n";
switch ($op) {
case "help":
......@@ -64,7 +65,7 @@ function watchdog_admin() {
print watchdog_view(check_input($id));
break;
default:
print watchdog_overview();
print watchdog_overview($type);
}
}
......
......@@ -17,16 +17,17 @@ function watchdog_cron() {
db_query("DELETE FROM watchdog WHERE ". time() ." - timestamp > ". variable_get("watchdog_clear", 604800));
}
function watchdog_overview() {
$colors = array(message => "#FFFFFF", special => "#836FFF", warning => "#FFAA22", httpd => "#77BB77", error => "#EE2C2C");
function watchdog_overview($type) {
$color = array(account => "#FFEEAA", message => "#FFFFFF", special => "#A49FFF", warning => "#FFAA22", httpd => "#99DD99", error => "#EE4C4C");
$query = array(account => "WHERE type = 'account'", regular => "WHERE type = 'message'", special => "WHERE type = 'special'", warning => "WHERE type = 'warning'", error => "WHERE type = 'error'", httpd => "WHERE type = 'httpd'");
$result = db_query("SELECT w.*, u.userid FROM watchdog w LEFT JOIN users u ON w.user = u.id ORDER BY timestamp DESC LIMIT 1000");
$result = db_query("SELECT w.*, u.userid FROM watchdog w LEFT JOIN users u ON w.user = u.id ". ($type ? $query[$type] : "") ." ORDER BY timestamp DESC LIMIT 1000");
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR><TH>date</TH><TH>message</TH><TH>user</TH><TH>operations</TH></TR>\n";
while ($watchdog = db_fetch_object($result)) {
if ($color = $colors[$watchdog->type]) {
$output .= " <TR BGCOLOR=\"$color\"><TD>". format_date($watchdog->timestamp) ."</TD><TD>". substr(check_output($watchdog->message), 0, 50) ."</TD><TD ALIGN=\"center\">". format_username($watchdog->userid) ."</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=watchdog&op=view&id=$watchdog->id\">details</A></TD></TR>\n";
if ($background = $color[$watchdog->type]) {
$output .= " <TR BGCOLOR=\"$background\"><TD>". format_date($watchdog->timestamp, "small") ."</TD><TD>". substr(check_output($watchdog->message), 0, 50) ."</TD><TD ALIGN=\"center\">". format_username($watchdog->userid) ."</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=watchdog&op=view&id=$watchdog->id\">details</A></TD></TR>\n";
}
}
$output .= "</TABLE>\n";
......@@ -52,9 +53,9 @@ function watchdog_view($id) {
}
function watchdog_admin() {
global $op, $id, $order;
global $op, $id, $type, $order;
print "<SMALL><A HREF=\"admin.php?mod=watchdog\">overview</A> | <A HREF=\"admin.php?mod=watchdog&op=help\">help</A></SMALL><HR>\n";
print "<SMALL><A HREF=\"admin.php?mod=watchdog&type=account\">account messages</A> | <A HREF=\"admin.php?mod=watchdog&type=message\">regular messages</A> | <A HREF=\"admin.php?mod=watchdog&type=special\">special messages</A> | <A HREF=\"admin.php?mod=watchdog&type=warning\">warning messages</A> | <A HREF=\"admin.php?mod=watchdog&type=error\">error messages</A> | <A HREF=\"admin.php?mod=watchdog&type=httpd\">httpd messages</A> | <A HREF=\"admin.php?mod=watchdog\">overview</A> | <A HREF=\"admin.php?mod=watchdog&op=help\">help</A></SMALL><HR>\n";
switch ($op) {
case "help":
......@@ -64,7 +65,7 @@ function watchdog_admin() {
print watchdog_view(check_input($id));
break;
default:
print watchdog_overview();
print watchdog_overview($type);
}
}
......
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