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
def caller_func_bla(): logger.debug('AA foo') logger.info('BB bar')
def test_debug(): logger.debug('test')