<commit_before>"""Contains code needed to initialize channelguide.  This should be run at
startup, before any real work starts.
"""

import logging
import logging.handlers
import random
import os
import sys
import traceback

from django.conf import settings
from django.core import signals
from django.dispatch import dispatcher

def init_logging():
    logger = logging.getLogger()
    logger.setLevel(logging.INFO)
    log_path = os.path.join(settings.SITE_DIR, 'log', 'cg.log')
    handler = logging.handlers.RotatingFileHandler(log_path, maxBytes=2**20)
    handler.setFormatter(logging.Formatter('%(asctime)s [%(levelname)s] %(message)s'))
    logger.addHandler(handler)
    logging.info("---- New Log -----")

def log_error():
    logging.error("Unhandled Exception: %s", traceback.format_exc())

def init_external_libraries():
    sys.path.insert(0, settings.EXTERNAL_LIBRARY_DIR)<commit_msg>Added login name info to the logs.<commit_after>"""Contains code needed to initialize channelguide.  This should be run at
startup, before any real work starts.
"""

import logging
import logging.handlers
import random
import os
import sys
import traceback

from django.conf import settings
from django.core import signals
from django.dispatch import dispatcher

def init_logging():
    logger = logging.getLogger()
    logger.setLevel(logging.INFO)
    log_path = os.path.join(settings.SITE_DIR, 'log', 'cg.log')
    handler = logging.handlers.RotatingFileHandler(log_path, maxBytes=2**20)
    handler.setFormatter(logging.Formatter('%(asctime)s [%(levelname)s] %(message)s'))
    logger.addHandler(handler)
    uid = os.getuid()
    login = os.environ.get('LOGNAME', '<unknown>')
    logging.info("---- New Log (uid: %s, login: %s) -----", uid, login)

def log_error():
    logging.error("Unhandled Exception: %s", traceback.format_exc())

def init_external_libraries():
    sys.path.insert(0, settings.EXTERNAL_LIBRARY_DIR)
{'fraction_non_alphanumeric': 0.12571428571428572, 'fraction_numerical': 0.004155844155844156, 'mean_word_length': 4.836363636363636, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '2930001', 'n_tokens_mistral': 594, 'n_tokens_neox': 585, 'n_words': 156}