<commit_before>"""Logging module for Pyjamas, mimicking CPython's logging module.

Usage example:
    from pyjamas import logging
    log = logging.getConsoleLogger()
    log.debug('This is a debug message')
"""
__author__ = '<NAME> <<EMAIL>>'

from pyjamas.logging.handlers import \
    AlertHandler, AppendHandler, ConsoleHandler, NullHandler
# blatantly copy everything from CPython's logging
from logging import getLogger, Formatter, StreamHandler, DEBUG, BASIC_FORMAT

# a handy replacement for BASIC_FORMAT printing nothing but the plain text
PLAIN_FORMAT = '%(message)s'

def getLoggerForHandler(handler, name=__name__, level=DEBUG, fmt=BASIC_FORMAT):
    """Use this function to easily include new loggers in your application,
    e.g. <code>log = logging.getLoggerForHandler(NullHandler())</code>"""
    formatter = Formatter(fmt)
    handler.setFormatter(formatter)
    logger = getLogger(name)
    logger.setLevel(level)
    logger.addHandler(handler)
    return logger

def getAlertLogger(name=__name__, level=DEBUG, fmt=BASIC_FORMAT):
    """A logger that shows any log message in a browser's alert popup dialog."""
    return getLoggerForHandler(AlertHandler(), name, level, fmt)
<commit_msg>add extra imports for pyjamas.logging<commit_after>"""Logging module for Pyjamas, mimicking CPython's logging module.

Usage example:
    from pyjamas import logging
    log = logging.getConsoleLogger()
    log.debug('This is a debug message')
"""
__author__ = '<NAME> <<EMAIL>>'

from pyjamas.logging.handlers import \
    AlertHandler, AppendHandler, ConsoleHandler, NullHandler
# blatantly copy everything from CPython's logging
from logging import getLogger, Formatter, StreamHandler
from logging import DEBUG, WARNING, INFO, BASIC_FORMAT

# a handy replacement for BASIC_FORMAT printing nothing but the plain text
PLAIN_FORMAT = '%(message)s'

def getLoggerForHandler(handler, name=__name__, level=DEBUG, fmt=BASIC_FORMAT):
    """Use this function to easily include new loggers in your application,
    e.g. <code>log = logging.getLoggerForHandler(NullHandler())</code>"""
    formatter = Formatter(fmt)
    handler.setFormatter(formatter)
    logger = getLogger(name)
    logger.setLevel(level)
    logger.addHandler(handler)
    return logger

def getAlertLogger(name=__name__, level=DEBUG, fmt=BASIC_FORMAT):
    """A logger that shows any log message in a browser's alert popup dialog."""
    return getLoggerForHandler(AlertHandler(), name, level, fmt)

{'fraction_non_alphanumeric': 0.09554655870445344, 'fraction_numerical': 0.0, 'mean_word_length': 5.224181360201511, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '5431838', 'n_tokens_mistral': 711, 'n_tokens_neox': 692, 'n_words': 225}