<commit_before>from flask import jsonify, redirect
from zaifbot.web.app import ZaifBot
from zaifbot.web.resources import strategies
from zaifbot.errors import ZaifBotError, InvalidRequest


__version__ = '0.0.6'


def zaifbot(import_name):
    app = ZaifBot(import_name)
    app.url_map.strict_slashes = False
    app.config['JSON_SORT_KEYS'] = False

    @app.errorhandler(InvalidRequest)
    def handle_invalid_usage(error):
        response = jsonify(error.to_dict())
        response.status_code = error.status_code
        return response

    resources = [strategies.resource]
    for resource in resources:
        app.register_blueprint(resource)

    @app.route('/')
    def root():
        return redirect('/strategies/', code=303)

    return app<commit_msg>log customize<commit_after>from flask import jsonify, redirect
from zaifbot.web.app import ZaifBot
from zaifbot.web.resources import strategies
from zaifbot.errors import ZaifBotError, InvalidRequest


__version__ = '0.0.6'


def zaifbot(import_name):
    app = ZaifBot(import_name)
    app.url_map.strict_slashes = False
    app.config['JSON_SORT_KEYS'] = False

    _customize_flask_logger()

    @app.errorhandler(InvalidRequest)
    def handle_invalid_usage(error):
        response = jsonify(error.to_dict())
        response.status_code = error.status_code
        return response

    @app.route('/')
    def root():
        return redirect('/strategies/', code=303)

    resources = [strategies.resource]
    for resource in resources:
        app.register_blueprint(resource)

    return app


def _customize_flask_logger():
    import logging
    from zaifbot.logger import bot_logger, bot_file_handler, bot_console_handler
    logger = logging.getLogger('werkzeug')
    logger.name = 'Web'
    logger.setLevel(logging.INFO)

    for hdlr in logger.handlers:
        logger.removeHandler(hdlr)

    logger.addHandler(bot_console_handler)
    logger.addHandler(bot_file_handler)
{'fraction_non_alphanumeric': 0.09049079754601227, 'fraction_numerical': 0.006134969325153374, 'mean_word_length': 3.693045563549161, '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': '1160689', 'n_tokens_mistral': 620, 'n_tokens_neox': 599, 'n_words': 127}