diff options
author | Dries Buytaert <dries@buytaert.net> | 2001-06-15 10:43:39 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2001-06-15 10:43:39 +0000 |
commit | 1045715f4486809993c679a2d09c993c15ef9d93 (patch) | |
tree | 22f02582dca470c6701293bd8be423ca6d6dd03a | |
parent | abcef73d19d8925a076d2bdadede933ed354141d (diff) | |
download | brdo-1045715f4486809993c679a2d09c993c15ef9d93.tar.gz brdo-1045715f4486809993c679a2d09c993c15ef9d93.tar.bz2 |
- 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.)
-rw-r--r-- | account.php | 20 | ||||
-rw-r--r-- | modules/account.module | 2 | ||||
-rw-r--r-- | modules/watchdog.module | 17 | ||||
-rw-r--r-- | modules/watchdog/watchdog.module | 17 |
4 files changed, 29 insertions, 27 deletions
diff --git a/account.php b/account.php index f341c1d1c..9b5ad6a3f 100644 --- a/account.php +++ b/account.php @@ -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' <$email>"); + watchdog("account", "new password: `$userid' <$email>"); 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 <$email> do not match"); + watchdog("account", "new password: '$userid' and <$email> 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]' <$new[real_email]>"); + watchdog("account", "new account: `$new[userid]' <$new[real_email]>"); 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."); diff --git a/modules/account.module b/modules/account.module index 62a9cb85d..4d81235da 100644 --- a/modules/account.module +++ b/modules/account.module @@ -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) { diff --git a/modules/watchdog.module b/modules/watchdog.module index e9ad84e87..761ae43b9 100644 --- a/modules/watchdog.module +++ b/modules/watchdog.module @@ -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); } } diff --git a/modules/watchdog/watchdog.module b/modules/watchdog/watchdog.module index e9ad84e87..761ae43b9 100644 --- a/modules/watchdog/watchdog.module +++ b/modules/watchdog/watchdog.module @@ -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); } } |