def get_enable_celery_error_reporting_function(site_name, from_address):
def enable_celery_email_logging(sender, signal, logger, loglevel, logfile, format, colorize, **kwargs):<EOL><INDENT>from celery import current_app<EOL>log.info('<STR_LIT>'.format(logger.name))<EOL>send_errors = current_app.conf['<STR_LIT>']<EOL>send_warnings = current_app.conf['<STR_LIT>']<EOL>if send_errors or send_warnings:<EOL><INDENT>error_email_subject = '<STR_LIT>'.format(site_name)<EOL>celery_handler = CeleryEmailHandler(from_address, current_app.conf['<STR_LIT>'],<EOL>error_email_subject)<EOL>if send_warnings:<EOL><INDENT>celery_handler.setLevel(logging.WARNING)<EOL><DEDENT>else:<EOL><INDENT>celery_handler.setLevel(logging.ERROR)<EOL><DEDENT>logger.addHandler(celery_handler)<EOL><DEDENT><DEDENT>return enable_celery_email_logging<EOL>
Use this to enable error reporting.  You need to put the following in your tasks.py or wherever you
want to create your celery instance:

celery = Celery(__name__)

enable_celery_email_logging = get_enable_celery_error_reporting_function('My Website [LIVE]', 'errors@mywebsite.com')
after_setup_logger.connect(enable_celery_email_logging)
after_setup_task_logger.connect(enable_celery_email_logging)