<commit_before>import logging
import logging.config
import time

from .config import load_config


def get_logger(cls, profile=None):
    if not profile:
        # profile = "{}.{}".format(cls.__module__, cls.__name__)
        profile = "{}".format(cls.__module__)

    logger = logging.getLogger(profile)
    return logger


def get_root_logger(profile='panoptes', log_config=None):
    """ Creates a root logger for PANOPTES

    Note:
        This creates the root logger for PANOPTES. All modules except `panoptes.core` should
        use the `get_logger` method located in this same module. See `get_logger` for
        details.

    Returns:
        logger(logging.logger): A configured instance of the logger
    """

    # Get log info from config
    log_config = log_config if log_config else load_config().get('logger', {})

    # Alter the log_config to use UTC times
    if log_config.get('use_utc', False):
        for name, formatter in log_config['formatters'].items():
            log_config['formatters'][name].setdefault('()', _UTCFormatter)

    # Configure the logger
    logging.config.dictConfig(log_config)

    # Get the logger and set as attribute to class<commit_msg>TimeRotatingFileHandlers will rotate on Sunday at 11am rather than at midnight. These are the `all` and `warn` handlers<commit_after>import logging
import logging.config
import time
import datetime

from .config import load_config


def get_logger(cls, profile=None):
    if not profile:
        # profile = "{}.{}".format(cls.__module__, cls.__name__)
        profile = "{}".format(cls.__module__)

    logger = logging.getLogger(profile)
    return logger


def get_root_logger(profile='panoptes', log_config=None):
    """ Creates a root logger for PANOPTES

    Note:
        This creates the root logger for PANOPTES. All modules except `panoptes.core` should
        use the `get_logger` method located in this same module. See `get_logger` for
        details.

    Returns:
        logger(logging.logger): A configured instance of the logger
    """

    # Get log info from config
    log_config = log_config if log_config else load_config().get('logger', {})

    # Alter the log_config to use UTC times
    if log_config.get('use_utc', False):
        for name, formatter in log_config['formatters'].items():
            log_config['formatters'][name].setdefault('()', _UTCFormatter)

    # Setup the TimeedRotatingFileHandler to backup in middle of day intead of middle of night
    for handler in ['all', 'warn']:
        log_config['handlers'][handler].setdefault('atAtime', datetime.time(hour=11, minute=30))

    # Configure the logger
    logging.config.dictConfig(log_config)

    # Get the logger and set as attribute to class
{'fraction_non_alphanumeric': 0.09784592917123038, 'fraction_numerical': 0.002190580503833516, 'mean_word_length': 3.4552845528455283, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4406376', 'n_tokens_mistral': 784, 'n_tokens_neox': 761, 'n_words': 258}