I am using standard SMTPHandler logger to catch my Python exceptions. Is there a way how to put exception name into the subject of the mail? It would be much better than with static subject, because Gmail (and not only Gmail) can group conversations according to subject and so it could group it according to the type of error.
E.g., if 50 completely the same errors occure + 1 different, I'd see two conversations in my inbox instead of 1 group consisting 51 emails, where I can very easily overlook the single different one.
Also, is there a way how to prevent sending still the same errors? E. g. somehow define my own function deciding if email is to be sent or not. The function would take some basic info in params so it could decide (e.g. cache & see if such an issue was already sent).
I browsed the docs, but I can't find anything like that. It seems to be very simple. If SMTPHandler can't do this, what would be the best and still simple alternative? Any neat libraries?
Thank you!
return formatter.format(record)
should be ->return formatter.formatMessage(record)
, otherwise you'll get: ValueError: Header values may not contain linefeed or carriage return characters – Blister