<commit_before>import logging
import logging.handlers
import math
import sys
from os import path

import arrow
import dateutil
import redis
import requests
from pymongo import uri_parser, MongoClient, GEOSPHERE, ASCENDING
from pymongo.errors import CollectionInvalid
from raven import Client as RavenClient

from settings import *


class NoExceptionFormatter(logging.Formatter):
    def format(self, record):
        record.exc_text = ''  # ensure formatException gets called
        return super(NoExceptionFormatter, self).format(record)

    def formatException(self, record):
        return ''


def get_logger(name, level=logging.INFO):
    logger = logging.getLogger(name)
    logger.setLevel(level)

    # Console
    handler = logging.StreamHandler(sys.stdout)
    fmt = logging.Formatter('%(levelname)s [%(name)s]: %(message)s')
    handler.setFormatter(fmt)
    logger.addHandler(handler)

    if WINDMOBILE_LOG_DIR:
        try:
            handler = logging.handlers.TimedRotatingFileHandler(
                path.join(path.expanduser(WINDMOBILE_LOG_DIR), name + '.log'), when='midnight', backupCount=20)
            fmt = NoExceptionFormatter('%(asctime)s %(levelname)s [%(name)s]: %(message)s', '%Y-%m-%dT%H:%M:%S%z')
            handler.setFormatter(fmt)
            logger.addHandler(handler)

            handler = logging.handlers.RotatingFileHandler(
                path.join(path.expanduser(WINDMOBILE_LOG_DIR), name + '.stacktraces.log'), maxBytes=50 * 10 ** 6)<commit_msg>Fixed log with stacktraces rolling rules<commit_after>import logging
import logging.handlers
import math
import sys
from os import path

import arrow
import dateutil
import redis
import requests
from pymongo import uri_parser, MongoClient, GEOSPHERE, ASCENDING
from pymongo.errors import CollectionInvalid
from raven import Client as RavenClient

from settings import *


class NoExceptionFormatter(logging.Formatter):
    def format(self, record):
        record.exc_text = ''  # ensure formatException gets called
        return super(NoExceptionFormatter, self).format(record)

    def formatException(self, record):
        return ''


def get_logger(name, level=logging.INFO):
    logger = logging.getLogger(name)
    logger.setLevel(level)

    # Console
    handler = logging.StreamHandler(sys.stdout)
    fmt = logging.Formatter('%(levelname)s [%(name)s]: %(message)s')
    handler.setFormatter(fmt)
    logger.addHandler(handler)

    if WINDMOBILE_LOG_DIR:
        try:
            handler = logging.handlers.TimedRotatingFileHandler(
                path.join(path.expanduser(WINDMOBILE_LOG_DIR), name + '.log'), when='midnight', backupCount=20)
            fmt = NoExceptionFormatter('%(asctime)s %(levelname)s [%(name)s]: %(message)s', '%Y-%m-%dT%H:%M:%S%z')
            handler.setFormatter(fmt)
            logger.addHandler(handler)

            handler = logging.handlers.RotatingFileHandler(
                path.join(path.expanduser(WINDMOBILE_LOG_DIR), name + '.stacktraces.log'), maxBytes=10 * 10 ** 6,
                backupCount=2)
{'fraction_non_alphanumeric': 0.10754098360655738, 'fraction_numerical': 0.004918032786885246, 'mean_word_length': 3.6580152671755726, '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': '76634', 'n_tokens_mistral': 928, 'n_tokens_neox': 881, 'n_words': 201}