logging: Reduce create_logger to new log_to_file.

The name `create_logger` suggests something much bigger than what this
function actually does -- the logger doesn't any more or less exist
after the function is called than before.  Its one real function is to
send logs to a specific file.

So, pull out that logic to an appropriately-named function just for
it.  We already use `logging.getLogger` in a number of places to
simply get a logger by name, and the old `create_logger` callsites can
do the same.
This commit is contained in:
Greg Price
2017-12-12 16:45:57 -08:00
parent 1c810baaef
commit b830b446f1
9 changed files with 40 additions and 39 deletions

View File

@@ -2,6 +2,7 @@ from typing import Any, Callable, Dict, Iterable, List, Set, Tuple, Text
from collections import defaultdict
import datetime
import logging
import pytz
from django.db.models import Q, QuerySet
@@ -17,9 +18,10 @@ from zerver.models import UserProfile, UserMessage, Recipient, Stream, \
Realm
from zerver.context_processors import common_context
from zerver.lib.queue import queue_json_publish
from zerver.lib.logging_util import create_logger
from zerver.lib.logging_util import log_to_file
logger = create_logger(__name__, settings.DIGEST_LOG_PATH)
logger = logging.getLogger(__name__)
log_to_file(logger, settings.DIGEST_LOG_PATH)
VALID_DIGEST_DAY = 1 # Tuesdays
DIGEST_CUTOFF = 5