My logging system has a few handlers, log file (INFO), an email handler (>ERROR), and a stream handler for optional debugging. When an error/exception/critical message occurs, I want the email handler to attach the log file from the file handler to the error email.
import logging
def initialize_logging():
logger = logging.getLogger()
logger.setLevel(logging.INFO)
file_handler = createFileHandler()
file_handler.setLevel(logging.INFO)
logger.addHandler(file_handler)
email_handler = createEmailHandler(file_handler.baseFileName)
email_handler.setLevel(logging.ERROR)
logger.addHandler(email_handler)
I found this example, but it's basically writing the handler from scratch. https://gist.github.com/LavinJ/238ccb229ac594a50b0a
I'd love if there was a simpler means of modifying the existing SMTPHandler
