Welcome to email_notification’s documentation!¶
Simple package to send email, if log file has error or if healthcheck endpoint is down.
Details:
email_notification¶
email_notification.main¶
-
email_notification.main.
checkhealth_send_email
(server_logfile, email_logfile, healthcheck_url, config)[source]¶ Check the health and send the log file as error message if server is down
- Args:
- server_logfile:
str
- path of file where log of server is stored
- email_logfile:
str
- path of file where log of this email is stored
- healthcheck_url:
str
- url for health checkhealth
- config:
dict
dict of config file
{ "TO":"example@gmail.com", "FROM":"example@gmail.com", "SMTP_SERVER":"smtp.gmail.com", # for gmail "PORT":"587", "PASSWORD": "password" }
- server_logfile:
- Return:
- send email if server is down and email is not already send
-
email_notification.main.
healthcheck
(url)[source]¶ check the health of server
- Args:
- url:
str
- url of healthcheck endpoint
- url:
- Return:
- if live True else False
-
email_notification.main.
send_email
(error_msd, filename, config)[source]¶ send email with error message from log file
- Args:
- error_msg:
list
- Error message, each sentence as list
- filename:
str
- filename of log file
- config:
dict
dict of config file
{ "TO":"example@gmail.com", "FROM":"example@gmail.com", "SMTP_SERVER":"smtp.gmail.com", # for gmail "PORT":"587", "PASSWORD": "password" }
- error_msg:
- Return:
- True if success else log error message
- Raise:
socket.error
if error while sending message.
email_notification.utils¶
email_notification.utils.utils module¶
-
email_notification.utils.utils.
logger
(logger_name='email_notification.utils.utils', filename='log.log', level=10)[source]¶ logger for logging
- Args:
- logger_name:
str
- name of logger
- filename:
str
- path and file name
- level:
str
- logging level
- logger_name:
- Return:
- logger funcation for logging:
logger