<commit_before>#!/usr/bin/env python
import mrglog
import importlib


class A(object):
    def __init__(self, level=None):
        if level is None:
            self.logger = mrglog.get_logger(
                'A class logger', module=True)
        else:
            self.logger = mrglog.get_logger(
                'A class logger', module=True, verbose_lvl=level)


class B(object):
    def __init__(self, level=0):
        self.logger = mrglog.USMLog.get_module_logger(
            'B class logger', verbose_lvl=level)


def test_it(logger, a_logger, b_logger):
    print('logger - verbose level {}\nA class logger - verbose level {}\n'
          'B class logger - verbose level {}'.format(logger.log_lvl,
                                                     a_logger.log_lvl,
                                                     b_logger.log_lvl))

    logger.error('nope error')
    logger.waived('ignore it', issue='some well known issue')
    logger.failed('ups fail')
    logger.passed('good again')
    logger.debug('some debug message')

    a_logger.passed('good A1')
    b_logger.failed('bad B1')
    a_logger.info('some info message 1')
    b_logger.fatal('some fatal message 1')

    logger.testStart('test1')

    logger.error('nope another error')
    logger.waived('ignore it again')
    logger.failed('ups fail once more')
    logger.passed('and good again')
    logger.warning('some warning message')

    a_logger.passed('good A2')
    b_logger.failed('bad B2')
    b_logger.passed('good B2')
    b_logger.info('some info message 2')

    logger.testEnd()

    a_logger.testStart('test2')

    logger.waived('ignore 3')
    logger.failed('fail 3')
    logger.passed('good 3')

    a_logger.passed('good A3')
    a_logger.failed('bad A3')
    b_logger.passed('good B3')
    b_logger.debug('some debug message 3')

    a_logger.testEnd()

    b_logger.testStart('test3')

    logger.waived('ignore 4')
    logger.passed('good 4')
    logger.rlLog('some log message', mrglog.LOG_LEVEL)
    logger.log(mrglog.ERROR, 'some error message')

    a_logger.passed('good A4')
    b_logger.passed('good B4')
    a_logger.warning('warning message 4')

    b_logger.testEnd()

    a_logger.close()
    b_logger.close()
    logger.close()


def reload_mrglog():
  try:
      importlib.reload(mrglog)
  except AttributeError:
      reload(mrglog)

print('----------------------------------------------------------------------')
print('----------------------------------------------------------------------')
print('-------------- verbose not set (prints everything) -------------------')
print('----------------------------------------------------------------------')
print('----------------------------------------------------------------------')

logger = mrglog.USMLog.get_logger('my logger 0')

a = A()
b = B()

test_it(logger, a.logger, b.logger)

print('----------------------------------------------------------------------')
print('----------------------------------------------------------------------')
print('-------- verbose set to 1 (prints only something interesting) --------')
print('----------------------------------------------------------------------')
print('----------------------------------------------------------------------')

reload_mrglog()<commit_msg>Fix demo indentation<commit_after>#!/usr/bin/env python
import mrglog
import importlib


class A(object):
    def __init__(self, level=None):
        if level is None:
            self.logger = mrglog.get_logger(
                'A class logger', module=True)
        else:
            self.logger = mrglog.get_logger(
                'A class logger', module=True, verbose_lvl=level)


class B(object):
    def __init__(self, level=0):
        self.logger = mrglog.USMLog.get_module_logger(
            'B class logger', verbose_lvl=level)


def test_it(logger, a_logger, b_logger):
    print('logger - verbose level {}\nA class logger - verbose level {}\n'
          'B class logger - verbose level {}'.format(logger.log_lvl,
                                                     a_logger.log_lvl,
                                                     b_logger.log_lvl))

    logger.error('nope error')
    logger.waived('ignore it', issue='some well known issue')
    logger.failed('ups fail')
    logger.passed('good again')
    logger.debug('some debug message')

    a_logger.passed('good A1')
    b_logger.failed('bad B1')
    a_logger.info('some info message 1')
    b_logger.fatal('some fatal message 1')

    logger.testStart('test1')

    logger.error('nope another error')
    logger.waived('ignore it again')
    logger.failed('ups fail once more')
    logger.passed('and good again')
    logger.warning('some warning message')

    a_logger.passed('good A2')
    b_logger.failed('bad B2')
    b_logger.passed('good B2')
    b_logger.info('some info message 2')

    logger.testEnd()

    a_logger.testStart('test2')

    logger.waived('ignore 3')
    logger.failed('fail 3')
    logger.passed('good 3')

    a_logger.passed('good A3')
    a_logger.failed('bad A3')
    b_logger.passed('good B3')
    b_logger.debug('some debug message 3')

    a_logger.testEnd()

    b_logger.testStart('test3')

    logger.waived('ignore 4')
    logger.passed('good 4')
    logger.rlLog('some log message', mrglog.LOG_LEVEL)
    logger.log(mrglog.ERROR, 'some error message')

    a_logger.passed('good A4')
    b_logger.passed('good B4')
    a_logger.warning('warning message 4')

    b_logger.testEnd()

    a_logger.close()
    b_logger.close()
    logger.close()


def reload_mrglog():
    try:
        importlib.reload(mrglog)
    except AttributeError:
        reload(mrglog)

print('----------------------------------------------------------------------')
print('----------------------------------------------------------------------')
print('-------------- verbose not set (prints everything) -------------------')
print('----------------------------------------------------------------------')
print('----------------------------------------------------------------------')

logger = mrglog.USMLog.get_logger('my logger 0')

a = A()
b = B()

test_it(logger, a.logger, b.logger)

print('----------------------------------------------------------------------')
print('----------------------------------------------------------------------')
print('-------- verbose set to 1 (prints only something interesting) --------')
print('----------------------------------------------------------------------')
print('----------------------------------------------------------------------')

reload_mrglog()
{'fraction_non_alphanumeric': 0.2948231364809473, 'fraction_numerical': 0.007894337331106725, 'mean_word_length': 1.494509655433548, '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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3253176', 'n_tokens_mistral': 1842, 'n_tokens_neox': 1729, 'n_words': 401}