On 06/16/2011 08:47 AM, Russell Keith-Magee wrote: > The behavior that is implemented in the 500 handler is a bit > convoluted, but it was designed to be a drop-in replacement for the > behavior that existed in 1.2 -- i.e., server error emails were not > sent in DEBUG mode. I remember looking at this exact problem; as I > recall, I was faced with the option of filtering in the handler (which > would mean providing a email handler that wouldn't send emails under > certain circumstances) or filtering at the logging call level. In the > interest of making the admin email handler general purpose, I opted > for the second option. > > Now, I'm not absolutely bound to this specific implementation, only to > the preservation of existing behavior without hobbling the email > handler as a general purpose tool.
This is a case for a custom Filter object [1]. The filter object implementation would only be a few lines, to reject logging when DEBUG is True, and can be attached to the admin email handler in the default logging configuration. [2] This way the logging call can occur in all code paths, and the admin email handler itself can remain general-purpose, but the backwards-compatible behavior can be maintained. Matt, if you'd be willing to open a ticket for this, that'd be helpful. If you feel like putting together a patch using the Filter approach, that'd be even better ;-) Carl [1] http://docs.python.org/library/logging.html#filter-objects [2] http://docs.python.org/library/logging.config.html#dictionary-schema-details -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.