<commit_before>from django.conf import settings


def init_log():
    import logging
    from redislog import handlers, logger
    l = logger.RedisLogger('hb.logger')
    l.setLevel(logging.DEBUG)
    l.addHandler(handlers.RedisHandler.to('hblog'))
    return l


def init_redis():
    """
    Returns redis connection.
    """
    import redis
    return redis.StrictRedis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.REDIS_DB)


def publish_to_proxy(msg):
    r = init_redis()
    r.publish('proxy_mgmt_request', msg)<commit_msg>redis_wrapper.py exports `logger`, an instance of init_log()<commit_after>from django.conf import settings


def init_log():
    from redislog import handlers, logger
    l = logger.RedisLogger('hb.logger')
    l.setLevel(logger.logging.DEBUG)
    l.addHandler(handlers.RedisHandler.to('hblog'))
    return l


def init_redis():
    """
    Returns redis connection.
    """
    import redis
    return redis.StrictRedis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.REDIS_DB)


def publish_to_proxy(msg):
    r = init_redis()
    r.publish('proxy_mgmt_request', msg)

logger = init_log()  # This line allows `from api.models.redis_wrapper import logger` - for convenience
{'fraction_non_alphanumeric': 0.11129032258064517, 'fraction_numerical': 0.0, 'mean_word_length': 4.086065573770492, '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': '6643378', 'n_tokens_mistral': 418, 'n_tokens_neox': 406, 'n_words': 86}