import yagmail
import datetime
import logging
from traceback import format_exc
import traceback
import logging


logger =  logging.getLogger(__name__)
logger.setLevel(logging.INFO)

formatter = logging.Formatter('%(asctime)s:%(levelname)s:%(name)s:%(message)s')

file_handler = logging.FileHandler('scheduler.log')
file_handler.setFormatter(formatter)

logger.addHandler(file_handler)

#this file alerts the developers whenever this script file stops running
# it also returns the error that has caused it
def send_email(e):
  logger.info("Sending out emails with error description")
  yag = yagmail.SMTP('<EMAIL>')

  recipients = { 
    '<EMAIL>': 'charles', 
    '<EMAIL>': 'steffan',
    '<EMAIL>': 'oumar',
    '<EMAIL>': 'mikael',
    '<EMAIL>': 'hassan',
    '<EMAIL>': 'tyler',
    '<EMAIL>': 'line',
    '<EMAIL>': 'armine'
  }

  date_of_failure = str(datetime.datetime.now())
  error_message = e
  contents = [
      "Automation has stopped working at" + date_of_failure + "\n" +error_message
  ]
  yag.send(recipients, 'subject', contents)

import yagmail
import datetime
import logging
from traceback import format_exc
import traceback
import logging


logger =  logging.getLogger(__name__)
logger.setLevel(logging.INFO)

formatter = logging.Formatter('%(asctime)s:%(levelname)s:%(name)s:%(message)s')

file_handler = logging.FileHandler('scheduler.log')
file_handler.setFormatter(formatter)

logger.addHandler(file_handler)

#this file alerts the developers whenever this script file stops running
# it also returns the error that has caused it
def send_email(e):
  logger.info("Sending out emails with error description")
  yag = yagmail.SMTP('<EMAIL>')

  recipients = { 
    '<EMAIL>': 'charles', 
    '<EMAIL>': 'steffan',
    '<EMAIL>': 'oumar',
    '<EMAIL>': 'mikael',
    '<EMAIL>': 'hassan',
    '<EMAIL>': 'tyler',
    '<EMAIL>': 'line',
    '<EMAIL>': 'armine'
  }

  date_of_failure = str(datetime.datetime.now())
  error_message = e
  contents = [
      "Automation has stopped working at" + date_of_failure + "\n" +error_message
  ]
  yag.send(recipients, 'subject', contents)

#this file alerts the developers whenever this script file stops running # it also returns the error that has caused it