Log the actual sending of digest emails in addition to queuing possible ones.

(imported from commit e43ac59e71620fe715db462347db228d5a950aed)
This commit is contained in:
Jessica McKellar
2014-01-08 11:33:12 -05:00
committed by Waseem Daher
parent 20f3b3af8f
commit d3f6c4ef36
2 changed files with 16 additions and 1 deletions

View File

@@ -12,6 +12,19 @@ from zerver.lib.actions import build_message_list, hashchange_encode, \
from zerver.models import UserProfile, UserMessage, Recipient, Stream, \
Subscription
import logging
log_format = "%(asctime)s: %(message)s"
logging.basicConfig(format=log_format)
formatter = logging.Formatter(log_format)
file_handler = logging.FileHandler(settings.DIGEST_LOG_PATH)
file_handler.setFormatter(formatter)
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logger.addHandler(file_handler)
# Digests accumulate 4 types of interesting traffic for a user:
# 1. Missed PMs
# 2. New streams
@@ -198,4 +211,5 @@ def handle_digest_email(user_profile_id, cutoff):
if enough_traffic(template_payload["unread_pms"],
template_payload["hot_conversations"],
new_streams_count, new_users_count):
logger.info("Sending digest email for %s" % (user_profile.email,))
send_digest_email(user_profile, html_content, text_content)