Project:Logging and alerts
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Dave Reid
Status:closed (fixed)

Issue Summary

Hi,

I like the email logging functionality. This is great to notice when something is going wrong with less frequented sites.

However, cron, menu rebuilds etc. may cause a real flood of emails as errors are triggered for every failed sql query. Of course one could argue that the error logic of some modules is not right, but my wish would be to limit the number of emails sent in a given interval.

eg. do net send more then 5 emails per hour. This is sufficient to notice that something is not ok, while keeping the mailbox clean.

This functionality should be ideally achieed without solely relying on the database (typical point of failure).

Comments

#1

Component:Miscellaneous» Code
Assigned to:Anonymous» Dave Reid

I've been working on this exact feature. I think we could name the feature "maximum e-mail frequency" and have the following options:
- Immediately (send an e-mail for every single warning)
- Whenever cron is run
- 5 minutes
- 15 minutes
- 30 minutes
- 1 hour
- 3 hours
- 6 hours
- 12 hours
- 1 day
- 1 week

I'm welcome to suggestions and improvements for the option's description

#2

Hey Dave,

your options are good. I am just not sure about your description. I'd suggest to send out an email immediately, unless a "block signal" has been set. Given certain constellations, a cron run may never occur.

However I think the major task will be, where to store the information on emails sent, while keeping up compatibility with different drupal installations.

My idea would be to create email-logs in both database and file system whenever an email is sent. Before sending out the next email, I'd check the max of the corresponding timestamps.

Logically, the configuration would have to be stored in two places too

#3

Having just received about 15,000 errors emails when we had a little bug on our development site, I wanted to see if we could revisit this idea. :)

I don't think limiting the emails by number make a lot of sense. You could have a limit of 5 and get 5 harmless errors and after that block 1 crucial error email that you really ought to see.

I think the main issue is duplication of the same error message over and over. It could probably see if a similar email was recently sent by checking the current error against the watchdog table, but that would probably be quite expensive in terms of db queries when things go wrong. A simpler solution might be to save the latest error message in the variables table with a counter. If that message was sent more than 'n' times as configured by the user, suppress the sending of the next error messages with exactly (or substantially) the same text. Let me know what you think, we might even be able to provide a patch according those lines if you think the idea is worthwhile.

-Daniel
Adulmec Ad Agency

#4

We submitted a potential patch here:

http://drupal.org/node/916976

-Daniel

#5

Status:active» closed (fixed)

A new feature to limit number of similar consecutive emails based on mihai_t's solution has been added to 6.x-2.x-dev and 7.x-2.x-dev releases.

nobody click here