#34 Add some logging when sending an email
Merged 3 years ago by pingou. Opened 3 years ago by pingou.

@@ -91,7 +91,7 @@ 

  

          _log.info(f"{len(logs)} invalid mapping found")

          if logs:

-             _log.info("-", "\n- ".join(logs))

+             _log.info("- %s", "\n- ".join(logs))

              logs_text = "\n- ".join(logs)

              message = f"""Dear Admin,

  

@@ -1,7 +1,11 @@ 

  from email.message import EmailMessage

+ import logging

  import smtplib

  

  

+ _log = logging.getLogger(__name__)

+ 

+ 

  def notify_packager(mail_server, admin_email, username, email):

  

      message = f"""Hello {username},
@@ -86,6 +90,7 @@ 

      address given with the subject and content and via the given email server.

      """

  

+     _log.info("Sending email to %s about: %s", to_addresses, subject)

      msg = EmailMessage()

      msg.add_header("To", ", ".join(to_addresses))

      msg.add_header("From", from_address)
@@ -95,3 +100,4 @@ 

      smtp = smtplib.SMTP(mail_server)

      smtp.sendmail(from_address, to_addresses, msg.as_string())

      smtp.quit()

+     _log.info("email sent")

Signed-off-by: Pierre-Yves Chibon pingou@pingoured.fr

1 new commit added

  • Fix logging the logs
3 years ago

Build failed.

  • tox : FAILURE in 8m 28s

rebased onto 0797f8705a7ce63096f9917b2ea938f48c65b090

3 years ago

Build succeeded.

  • tox : SUCCESS in 12m 42s

rebased onto f47f08c

3 years ago

Build succeeded.

  • tox : SUCCESS in 6m 56s

Thanks for the review :)

Pull-Request has been merged by pingou

3 years ago