Exemplo n.º 1
0
def test_match():

    # Match based on string
    with capture_log('info', 'foo') as log:
        logger.info('AA foo')
        logger.info('BB bar')  # no foo
        logger.debug('CC foo')  # too high level
        logger.info('DD fXo')  # no foo

    assert len(log) == 1
    assert 'AA' in log[0]

    # Match based on regexp
    with capture_log('info', re.compile('f.o')) as log:
        logger.info('AA foo')
        logger.info('BB bar')  # no foo
        logger.debug('CC foo')  # too high level
        logger.info('DD fXo')

    assert len(log) == 2
    assert 'AA' in log[0]
    assert 'DD' in log[1]

    # No match
    with capture_log('info', '') as log:
        logger.info('AA foo')
        logger.info('BB bar')
        logger.debug('CC foo')  # too high level
        logger.info('DD fXo')

    assert len(log) == 3
Exemplo n.º 2
0
def test_match():

    # Match based on string
    with capture_log('info', 'foo') as log:
        logger.info('AA foo')
        logger.info('BB bar')  # no foo
        logger.debug('CC foo')  # too high level
        logger.info('DD fXo')  # no foo

    assert len(log) == 1
    assert 'AA' in log[0]

    # Match based on regexp
    with capture_log('info', re.compile('f.o')) as log:
        logger.info('AA foo')
        logger.info('BB bar')  # no foo
        logger.debug('CC foo')  # too high level
        logger.info('DD fXo')

    assert len(log) == 2
    assert 'AA' in log[0]
    assert 'DD' in log[1]

    # No match
    with capture_log('info', '') as log:
        logger.info('AA foo')
        logger.info('BB bar')
        logger.debug('CC foo')  # too high level
        logger.info('DD fXo')

    assert len(log) == 3
Exemplo n.º 3
0
 def caller_func_bla():
     logger.debug('AA foo')
     logger.info('BB bar')
Exemplo n.º 4
0
def test_debug():

    logger.debug('test')
Exemplo n.º 5
0
 def caller_func_bla():
     logger.debug('AA foo')
     logger.info('BB bar')
Exemplo n.º 6
0
def test_debug():

    logger.debug('test')